Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to set root/main/default servlet in Tomcat 5.5

Status
Not open for further replies.

leesiulung

Programmer
May 15, 2007
2
US
I'm on a shared hosting account with Tomcat 5.5 and cannot figure out why I can't set the default servlet. I want all incoming requests regardless of the relative path, to be handled by the Redirect servlet. There is only one servlet in the whole project.

Some examples

-> Redirect servlet (not working)
-> Redirect servlet (not working)
-> Redirect servlet
-> Redirect servlet

With the below web.xml file, the last two above works just fine, but the first two gives a 403 error. What gives, I followed the Tomcat documentation to the teeth... It seems to work on my development server, but not on the shared hosting. Is this a setting anyone would block? Any help would be much appreciated.

The full web.xml setting below:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="[URL unfurl="true"]http://java.sun.com/xml/ns/j2ee"[/URL] xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xsi:schemaLocation="[URL unfurl="true"]http://java.sun.com/xml/ns/j2ee[/URL] [URL unfurl="true"]http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">[/URL]
 
 	<display-name>Redirect</display-name>
 
 	<servlet>
 		<display-name>Redirect</display-name>
 		<servlet-name>Redirect</servlet-name>
 		<servlet-class>com.somedomain.Redirect</servlet-class>
 		<init-param>
 			<param-name>host</param-name>
 			<param-value>[URL unfurl="true"]www.myotherdomain</param-value>[/URL]
 		</init-param>
 		<init-param>
 			<param-name>redirect-type</param-name>
 			<param-value>301</param-value>
 		</init-param>
 	</servlet>
 
 	<servlet-mapping>
 		<servlet-name>Redirect</servlet-name>
 		<url-pattern>/</url-pattern>
 	</servlet-mapping>
 
</web-app>


I tried adding other mappings as well that didn't work, such as :

Code:
 <servlet-mapping>
 		<servlet-name>Redirect</servlet-name>
 		<url-pattern>/*</url-pattern>
 	</servlet-mapping>

What would happen if I try an empty url-pattern?

Code:
<servlet-mapping>
 		<servlet-name>Redirect</servlet-name>
 		<url-pattern></url-pattern> 
 	</servlet-mapping>

Any help would be much appreciated. I tried workarounds, by using an index.jsp file to supplement, but that isn't working quite right either. I prefer to have it setup properly though.... Please Help!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top