Jim Lindsay wrote:
>
> I am not able to get session or application scope tracking to work for some
> reason. Currently the code is trying to use
> application tracking, but I know I should be using session tracking for
> items that are for the user session.
>
> In my userLoggidIn.jsp page I have:
> Error Message = < <%= application.getAttribute("errorMessage") %> >
>
> In my servlet I have:
> application.setAttribute("errorMessage", "NO error message");
> response.sendRedirect( response.encodeRedirectURL("/userLoggedIn.jsp");
>
> The output is *always*: "Error Message = < null >". What the heck am I
> doing wrong?
Note that the sendRedirect() method takes a "server-relative" path as
opposed to a "context-relative" path (as most other methods require).
In your example, you redirect to http://yourserver/userLoggedIn.jsp. If
your servlet is not part of the default context, you're redirecting to a
different application; hence, the application scope attribute is not
available. Try this instead:
String jspPath = request.getContextPath() + "/userLoggedIn.jsp";
response.sendRedirect( response.encodeRedirectURL(jspPath);
This way your redirect works as expected no matter which context path
you use for the application.
Hans
--
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://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com