Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[equinox-dev] HttpServletRequest.getServletPath() behavior on HTTP Service does not match Jetty?

Dear All:

Sorry for bothering. We use HttpServletRequest.getServletPath() in OpenMRS,
and I have noticed a difference in behavior between HTTP Service (both
Equinox and Felix) 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/p30138033/my-webapp.zip my-webapp.zip 

mvn clean install -DskipTests && mvn jetty:run -Djetty.port=9999

Request: http://localhost:9999/my-webapp/index.htm
Result of getServletPath: [/index.htm]

2) Equinox version (exact same servlet):

http://old.nabble.com/file/p30138033/test.equinox.zip test.equinox.zip 

mvn clean install pax:provision

Request: http://localhost:8080/hello/index.htm
Result of getServletPath: [/hello]

Here is the servlet:
http://old.nabble.com/file/p30138033/HelloWorld.java HelloWorld.java 

and the web.xml:
http://old.nabble.com/file/p30138033/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 Equinox and/or Felix 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
-- 
View this message in context: http://old.nabble.com/HttpServletRequest.getServletPath%28%29-behavior-on-HTTP-Service-does-not-match-Jetty--tp30138033p30138033.html
Sent from the Equinox - Dev mailing list archive at Nabble.com.



Back to the top