First let me start by saying that this is not a bug...nor a
misinterpretation of the specs. Servlets 2.2 specification introduces the
concept of "web-app" contexts. A context is just that, an isolated space
where your web application runs. It has no notion of anything outside of it.
This is the reason you can take a "war" archive and send it to your friend
and expect it to work :) When you do a sendRedirect(redirectPath), it's
always interpreted as "relative to the context" unless you qualify it as
"absolute".
The fact that this works in other servlet servers is that most of these
servers have legacy code from Servlets 2.0, 2.1 that never got changed. Even
though Orion could change to accept this functionallity, it is highly
undesired, since it would break the concept of an isolated web-application.
If you need to access anything within the context, you can use a block of
code like this (or you can make a bean out of it to simplify things):
String requestURL=HttpUtils.getRequestURL(request).toString();
String absolute=requestURL.substring(0,
requestURL.length()-request.getRequestURI().length());
response.sendRedirect(absolute+"/myothercontext/index.jsp");
This solution takes all the ambiguity away and makes your application work
in Orion,Tomcat,etc. Although it is never a good idea to statically code
those absolute urls in the web-app, as it is best practice to look them up
in the descriptor through env-entries ....
I hope I have cleared this up. If you have any more questions on the matter,
shoot! :)
-- Victor Salaman
> -----Original Message-----
> From: Christian Sell [mailto:[EMAIL PROTECTED]]
> Sent: Friday, July 14, 2000 4:29 PM
> To: Orion-Interest
> Subject: Re: sendRedirect in orion and jrun
>
>
> not quite. Going to another application is done via
> ServletContext.getContext(). This is from the api docs for
> getRequestDispatcher:
>
> "The pathname must begin with a "/" and is interpreted as
> relative to the
> current context root. Use getContext to obtain a RequestDispatcher for
> resources in foreign contexts. This method returns null if the
> ServletContext cannot return a RequestDispatcher"
>
> this is what getContext says:
>
> "This method allows servlets to gain access to the context
> for various parts
> of the server, and as needed obtain RequestDispatcher objects from the
> context. The given path must be absolute (beginning with "/") and is
> interpreted based on the server's document root. "
>
> strange, though that they would call a path absolute that
> starts with "/".
> Anyway, in case of sendRedirect (and everywhere else unless otherwise
> mentioned, as Magnus said) I vote for "context root relative"
>
>
> -----Original Message-----
> From: Stephan Schmidt <[EMAIL PROTECTED]>
> To: Orion-Interest <[EMAIL PROTECTED]>
> Date: Samstag, 15. Juli 2000 04:00
> Subject: Re: sendRedirect in orion and jrun
>
>
> >Hi,
> >
> >I think Orion is wrong (if expands / to your relative directory)
> >
> >http://www.foobar.com/bar/
> >
> >"/" should expand to http://www.foobar.com
> >"" should expand to http://www.foobar.com/bar
> >"/bar" should expand to http://www.foobar.com/bar
> >
> >if you can't expand to other things than "/" -> "/bar", you cannot
> >redirect to another application directory on your server.
> >
> >-stephan
> >
> >At 11:18 14.07.00 -0500, you wrote:
> >I'm struggling with this too. Tomat does what JRun does, interprets
> relative
> >URLs as arelative to the root rather than the the context. I
> think Orion's
> >implementation makes more sense, but the spec is unclear. It
> simply says
> >that relative URLs must be translated to abosolute URLs, that's all.
> >
> >If Tomcat is the reference implementation, then by definition it is
> "right",
> >even if it's wrong. That being said, unless Tomcat changes itself,
> shouldn't
> >Orion follow suite?.
> >
> >--
> >Duane Fields
> >[EMAIL PROTECTED]
> >Managing Engineer, Web Development
> >
> >
> >----- Original Message -----
> >From: ""Jen Hsien Huang"" <[EMAIL PROTECTED]>
> >Newsgroups: uo.listserv.orion
> >Sent: Friday, July 14, 2000 10:33 AM
> >Subject: RE: sendRedirect in orion and jrun
> >
> >
> > > Of cause, since API says server will resolve relative, so Orion is
> right.
> > >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> [mailto:owner-]On Behalf Of
> >Christian Sell
> > > Sent: Friday, July 14, 2000 7:43 PM
> > > To: Orion-Interest
> > > Subject: sendRedirect in orion and jrun
> > >
> > >
> > > from within a servlet, i am making the following call:
> > >
> > > response.sendRedirect("/");
> > >
> > > interesting thing: in orion, this takes me back to the
> context root of
> the
> > > web application. In JRun 3.0, it takes me to the root of
> the web server.
> >As
> > > far as I can see, the API docs say that the server will
> resolve relative
> > > URLs, but which one is right in this case?
> > >
> > > Christian Sell
> > >
> >
> >
>
>