Problems with Spring, Jetty and SimpleUrlHandlerMapping

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Problems with Spring, Jetty and SimpleUrlHandlerMapping

Ståle Undheim
After all the fuss I have heard about Spring, I decided I wanted to
check it out for myself.

My basic setup for running webapps is eclipse, using the jetty
launcher to start jetty applications (Basically, it just generates a
big command line that it uses to start jetty, including the classpath
from eclipse, and setting the webapp folder to where I choose).

I started out with the example at
but I haven't made it past the first page yet.

Basically I have to go to the URL
http://localhost:8080/springapp/hello.htm - which will use the
argument "hello.htm" to map to my class.

Now, by now you might think that this belongs in the Spring framework
mailling list. The reason I post here is that when I examined the
code, I saw how Spring extracts the "hello.htm" part from the request
URI. Condensed, the code is something like this:

Note: this is a root webapp, springapp is the servlet.

String contextPath = request.getContextPath() # ""
String requestURI = request.getRequestURI() # "/springapp/hello.htm"

String pathWithinApp = requestUri.substring(contextPath.length()) #
String servletPath = request.getServletPath() # "/springapp/hello.htm"

return pathWithinApp.substring(servletPath.length()) # ""

So, the result of pathWithinApp and servletPath is the same, while I
suspect Spring expects servletPath to only contain the servlet part
("/springapp") of the URI. I was unsure wether this was Spring using
the servlet API wrong or Jetty implementing it wrong. But the JavaDoc
on the Servlet API says:
Returns the part of this request's URL that calls the servlet. This
includes either the servlet name or a path to the servlet, but does
not include any extra path information or a query string. Same as the
value of the CGI variable SCRIPT_NAME

Am I doing something wrong with Spring or Jetty? Or have I found a bug?
Tested with 4.2.24 and 5.1.3 version of Jetty, Spring framework 1.2.

SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate
online with coworkers and clients while avoiding the high cost of travel and
communications. There is no equipment to buy and you can meet as often as
you want. Try it free.<a href="">
Jetty-support mailing list
[hidden email]