Rodrigo Gevaerd wrote:
>
> Does anyone know if the session will remain the same if you forward a
> request to another servlet context like that, or there will be another
> session in the other context?
> I would say that the jsp 'application' variable is another, because the
> 'application' is the ServletContext itself.
>
> []'s,
>
> Rodrigo.
Sessions are unique per application, so if you forward to another context
(i.e. "application"), you will not have access to the same session.
Hans
> > According to the Servlet spec, you can get access to another
> > ServletContext
> > than the one you're running in with:
> >
> > getServletContext().getContext("/othercontext");
> >
> > So, something like this should work for your example:
> >
> > ServletContext loginCtx = getServletContext().getContext("/login");
> > RequestDispatcher rd =
> > loginCtx.getRequestDispatcher("/servlet/LoginServlet");
> > rd.forward(request, response);
> >
> > Note, however, that the container may not allow you to get access to
> > the other context due to security constraints. If so, it will return
> > null instead. How to declare context security constraints is vendor
> > dependent.
> >
> > Hans
> > --
> > Hans Bergsten [EMAIL PROTECTED]
> > Gefion Software http://www.gefionsoftware.com
> > Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets