getContextPath() woes [message #114217] |
Wed, 16 July 2008 01:12 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Hi,
I am developing a project with servletbridge, and am having some issues
with getContextPath() in
org.eclipse.equinox.http.helper.ContextPathServletAdaptor$Ht tpServletRequestAdaptor
and org.eclipse.equinox.http.servlet.internal.HttpServletRequest Adaptor.
In
org.eclipse.equinox.http.helper.ContextPathServletAdaptor$Ht tpServletRequestAdaptor
(module: equinox-incubator/org.eclipse.equinox.http.helper),
getContextPath() returns super. getContextPath() with or without the
ContextPathServletAdaptors contextPath, depending on whether or not the
javax.servlet.include.request_uri request attribute is set.
So with a web app of MyWebApp and an bundle of MyBundle1 I get
returned a context path of /MyWebApp when Im inside of a .jsp file
included (RequestDispatch.include) from a Struts Action servlet, and
/MyWebApp/MyBundle1 otherwise. I dont understand why these are
different, and as we have code in both cases which invokes getContextPath,
these inconsistent return values dont work well. To get around this I
have commented out the code in
ContextPathServletAdaptor$HttpServletRequestAdaptor.getConte xtPath() for
the include case. But Im wondering if this really the way it is supposed
to work, or am I perhaps doing something completely wrong?
The second issue is with getContexPath() in the internal
HttpServletRequestAdaptor (module: org.eclipse.equinox.http.servlet).
Here super.getServletPath() is optionally appended to
super.getContextPath() depending once again on whether the
javax.servlet.include.request_uri request attribute is set. This works
fine for me on Tomcat, but running the same jsf (faces) code on IBM
Websphere 6.1 gives me a messed up context path. In both cases
javax.servlet.include.request_uri is not set, so the method appends the
servlet path which happens to be an empty string in Tomcat, and non-empty
in WebSphere. Upon return from this method we end up back in the above
mentioned ContextPathServletAdaptor$HttpServletRequestAdaptor, which tacks
on the bundle name.
By way of example, when I send a request to
http://mymachine:8080/MyWebApp/MyBundle2/testJsfPath.faces, in Tomcat
request.getContextPath() in the jsp returns "/MyWebApp/MyBundle2" while
Websphere returns "/MyWebApp/MyBundle2/testJsfPath.jsp/MyBundle2". The
difference is the /MyBundle2/testJsfPath.jsp which Websphere returns as
the servlet path above and Tomcat does not. Presumably this is because
the original request object passed in and wrapped is different:
com.ibm.ws.webcontainer.srt.SRTServletRequest for Websphere and
org.apache.catalina.connector.Request for Tomcat (or something like that).
What I dont understand is why we tack on the servlet path in either
case. Here my workaround is to comment out code in
HttpServletRequestAdaptor.getContextPath() so as not to return the servlet
path.
Can anyone enlighten me?
Thanks.
~ Clarence
|
|
|
Re: getContextPath() woes [message #114232 is a reply to message #114217] |
Wed, 16 July 2008 04:24 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Hi Clarence,
Please open a bug report.
From what you describe it sounds like we might not be doing the context path
mapping correctly for the original request when a request has been
"included".
Both issues you mention sound like they might be related.
As you've found, one of the differences between Websphere and tomcat is in
how servlet path is calculated when handling requests via extensions (like
*.jsp). Tomcat will use a servlet path of "" whereas Websphere will use the
path to the jsp as the servlet path.There is code in the BridgeServlet to
try to normalize the situation however it sounds like similar to your first
problem we might normalize the "include" attributes but not the original
servlet request.
-Simon
"Clarence Stad" <clarence.stad@sap.com> wrote in message
news:cde379896d8feeb882d62b3a07733275$1@www.eclipse.org...
> Hi,
>
> I am developing a project with servletbridge, and am having some issues
> with getContextPath() in
> org.eclipse.equinox.http.helper.ContextPathServletAdaptor$Ht tpServletRequestAdaptor
> and org.eclipse.equinox.http.servlet.internal.HttpServletRequest Adaptor.
>
> In
> org.eclipse.equinox.http.helper.ContextPathServletAdaptor$Ht tpServletRequestAdaptor
> (module: equinox-incubator/org.eclipse.equinox.http.helper),
> getContextPath() returns super. getContextPath() with or without the
> ContextPathServletAdaptor
|
|
|
Powered by
FUDForum. Page generated in 0.03046 seconds