tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin van den Bemt" <m...@mvdb.com>
Subject RE: response.sendRedirect vs. requestDispatcher.forward
Date Wed, 30 May 2001 23:37:51 GMT
If you webserver is serving in /usr/local/apache/htdocs, you are redirecting
to /usr/local/apache/htdocs/login.jsp, which is handled in this example by
apache, who doesn't know anything about jsp files. (that's why you got
tomcat in the first place...)

Mvgr,
Martin

> -----Original Message-----
> From: Brandon Cruz [mailto:bcruz@norvax.com]
> Sent: Thursday, May 31, 2001 1:31 AM
> To: tomcat-user@jakarta.apache.org
> Subject: RE: response.sendRedirect vs. requestDispatcher.forward
>
>
> Has anyone figured out why response.sendRedirect("/login.jsp")
> will not work
> when using apache-tomcat with mod_jk?  It gets all screwed up and prints a
> bunch of header information out to the page...is there a way around it
> besides using javascript to redirect the page?
>
> Brandon Cruz
>
> -----Original Message-----
> From: A Yang [mailto:ayang_ml@yahoo.ca]
> Sent: Wednesday, May 30, 2001 1:13 PM
> To: tomcat-user@jakarta.apache.org
> Subject: RE: response.sendRedirect vs. requestDispatcher.forward
>
>
> Hi,
>
> Thanks for the help. As it turns out, switching
> between requestDispath.forward and response.redirect
> will trip you up because of differences in what they
> expect as their parameters.
>
> RequestDispatch.forward takes a URL that is a RELATIVE
> path but also requires a leading slash.
>
> If you are brilliant (like myself) and you change your
> code to use response.encodeRedirectURL but you KEEP
> that leading slash, well then. Your response will
> treat it like an absolute path and wind up plunking
> you into a different servlet context, which Tomcat
> will generate a new session for.
>
> Thanks again for your help,
> Andy
>
> --- Martin van den Bemt <mvdb@mvdb.com> wrote:
> > A different hostname creates a new session which
> > could be the problem here..
> > (so http://www.example.com and http://example.com
> > create a different session even it's the same
> > server/context/etc..
> >
> > Mvgr,
> > Martin
> >
> > > -----Original Message-----
> > > From: Alex Fernandez [mailto:afm229@tid.es]
> > > Sent: Tuesday, May 29, 2001 4:57 PM
> > > To: tomcat-user@jakarta.apache.org
> > > Subject: Re: response.sendRedirect vs.
> > requestDispatcher.forward
> > >
> > >
> > > Conceptually, requestDispatcher.forward() is
> > different from
> > > response.sendRedirect().
> > >
> > > In forward(), you are moving inside the same
> > webapp, and as such it
> > > doesn't even reach the client browser. The session
> > is maintained.
> > >
> > > In sendRedirect(), you're instead moving across
> > webapps, and it's the
> > > browser that redirects to the specified location.
> > In fact, it doesn't
> > > even need to be another servlet, you may redirect
> > to an ASP or a static
> > > page. New request and response are created.
> > >
> > > It seems strange that the session is not
> > maintained, though, since both
> > > requests come from the same browser. Perhaps it's
> > a bug?
> > >
> > > Un saludo,
> > >
> > > Alex.
> > >
> > > A Yang wrote:
> > > >
> > > > Hi All,
> > > >
> > > > Does anyone know offhand whether the Java
> > Servlet
> > > > specification requires a new HttpSession to be
> > created
> > > > when using HttpServletResponse.sendRedirect()?
> > > >
> > > > In a servlet, I was using:
> > > >
> > > >
> > >
> >
> getServletConfig().getServletContext().getRequestDispatcher("/Resu
> > > lt.jsp").forward(req,
> > > > resp);
> > > >
> > > > at the end of a sequence of pages/servlets, but
> > I
> > > > wanted to replace it with
> > > >
> > > > response.sendRedirect("/Result.jsp");
> > > >
> > > > instead. The result page prints out the contents
> > of
> > > > several javabeans which are stored in the
> > session.
> > > >
> > > > This worked fine when all I used were
> > > > requestDispatcher.forward but with
> > > > response.sendRedirect(), all of my session
> > attributes
> > > > are gone! In fact, the session id is different
> > after
> > > > the sendRedirect.
> > > >
> > > > I'm pretty sure the session is supposed to
> > survive
> > > > across any series of GET's and POST's until it
> > is
> > > > invalidated explicitly (or timed out).
> > > >
> > > > Any thoughts? I'm using Tomcat 3.2.1
> > > >
> > > > Thanks.
> > > >
> > > >
> >
> _______________________________________________________
> > > > Do You Yahoo!?
> > > > Get your free @yahoo.ca address at
> > http://mail.yahoo.ca
> > >
> >
>
>
> _______________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.ca address at http://mail.yahoo.ca
>
>


Mime
View raw message