Stan Bailes wrote:
>
> But what about about absolute URLs in requests?
>
> For example, if the request line looks like:
>
> GET http://java.sun.com:80/index.html HTTP/1.1
>
> The documentation for getRequestURI() specifies that the value
> returned contains the protocol part up until the start of the query
> string, which seems to be in conflict with the other requirements
> specified above.
>
At least for the 2.2 specification, that statement in the Javadoc comments is
incomplete, because it fails to point out that the scheme, host, and port are
stripped off for the request URI. In addition, the second example case is
incorrect. In your example above, the getRequestURI() call should return
"/index.html".
>
> Can somebody clarify this? What should getRequestURI() and
> getContextPath() return in this case?
>
As mentioned above, getRequestURI() returns "/index.html". You cannot examine
a request URI and determine what getContextPath() will return unless you know
how context paths have been configured in your server. For example, consider
the case of Jakarta Tomcat in it's default configuration, which has a context
mapped to "/examples" along with the default context.
Given a request URI "/examples/index.html" you will get a context path of
"/examples".
Given a request URI of "/otherdir/index.html", you will get a context path of
"" because it will be handled by the default context.
>
> Stan Bailes
> Quadcap Software
> http://www.quadcap.com
>
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html