views:

987

answers:

2

I am having an issue where Tomcat is treating extra path information as part of the servlet name. This is breaking a bunch of RESTFul functionality in our webapp (we use extra path info rather than ?name=value pairs for crawler friendly links).

It was working correctly before, but it broke after adding explicit mappings and removing the Invoker servlet that we previously used to serve our servlets. For example consider the following link:

http://mydomain.com/servlet/MyServlet/param1/param2/param3

MyServlet used to be called correctly, and "/param1/param2/param3" was returned by getPathInfo() on the HttpServletRequest.

Now, it appears that Tomcat is trying to load MyServlet/param1/param2/param3 as the servlet:

[23/Sep/2008:16:44:23 -0700] "GET /servlet/MyServlet/param1/param2/param3 HTTP/1.0" 404

Here is the way they are defined and mapped in the web.xml, and just hitting "http://mydomain.com/servlet/MyServlet" works fine.

<servlet>
  <servlet-name>MyServlet</servlet-name>
  <servlet-class>com.myclass.etcetera.MyServlet</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>MyServlet</servlet-name>
  <url-pattern>/servlet/MyServlet</url-pattern>
</servlet-mapping>
+2  A: 

You need to map it to /servlet/MyServlet/*

You are missing the trailing "/*".

erickson
A: 

That was great. Thanks alot.

JBonglo