Hi,
The problem with your assumption about the servlet path is in fact a
problem with your servlet registration with Jetty.
In the web.xml you have the following servlet mapping:
<servlet-mapping>
<servlet-name>HelloWorldExample</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
According to the Spec (e.g. Servlet API 2.3, SRV.11.2, Specification of
Mappings): "A string containing only the '/' character implies the
"default" servlet of the application. In this case the servlet path is
the request URI minus the context path and the path info is null."
I would assume, that if you would register the servlet with "/*" (notice
the trailing asterisk) you might see the same result in Jetty as you see
in Felix and Equinox.
HTH
Regards
Felix
Am Donnerstag, den 04.11.2010, 19:04 -0700 schrieb misha680:
> Dear All:
>
> Sorry for bothering. We use HttpServletRequest.getServletPath() in OpenMRS,
> and I have noticed a difference in behavior between HTTP Service (both Felix
> and Equinox) and Jetty, and was wondering if there was some explanation for
> this.
>
> My apologies if I am missing something simple. Here are two versions:
>
> 1) Jetty version:
>
> http://old.nabble.com/file/p30137615/my-webapp.zip my-webapp.zip
>
> Request: http://localhost:9999/my-webapp/index.htm
> Result of getServletPath: [/index.htm]
>
> 2) Felix version (exact same servlet):
>
> http://old.nabble.com/file/p30137615/test.zip test.zip
>
> Request: http://localhost:8080/hello/index.htm
> Result of getServletPath: [/hello]
>
> Here is the servlet:
> http://old.nabble.com/file/p30137615/HelloWorld.java HelloWorld.java
>
> and the web.xml:
> http://old.nabble.com/file/p30137615/web.xml web.xml
>
> for the Jetty version.
>
> Fyi, per Servlet 2.1 API spec:
> http://download.oracle.com/docs/cd/E17802_01/products/products/servlet/2.1/api/javax.servlet.http.HttpServletRequest.html#getServletPath()
>
> "public abstract String getServletPath()
> Gets the part of this request's URI that refers to the servlet being
> invoked. Analogous to the CGI variable SCRIPT_NAME."
>
> and, e.g.,
> http://www.perlfect.com/articles/cgi_env.shtml
>
> "SCRIPT_NAME
>
> The virtual path from which the script is executed.
> This is very useful if your script will output html code that contains calls
> to itself. Having the script determin its virtual path, (and hence, along
> with DOCUMENT_ROOT, its full URL) is much more portable than hard coding it
> in a configuration variable. Also, if you like to keep a log of all script
> accesses in some file, and want to have each script report its name along
> with the calling parameters or time, it is very portable to use SCRIPT_NAME
> to print the path of the script."
>
> The Jetty behavior seems correct even for Servlet API 2.1. However, clearly
> both Felix and Equinox chose to implement this differently from the Jetty
> HTTP Server.
>
> Am I missing something?
>
> More importantly, where would I get the relevant string (i.e. /index.htm)
> from the Felix and/or Equinox implementations of HttpServletRequest?
>
> Thank you
> Yours
> Misha
>
> p.s. The relevant OpenMRS controller:
>
> http://source.openmrs.org/browse/~raw,r=16192/OpenMRS/trunk/web/src/main/java/org/openmrs/web/controller/patient/ShortPatientFormValidator.java
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]