I'm trying to pass a value on one JSP page (x) to another JSP (y).  The
transition from page x to page y is done via a link on page x.

I was under the impression that if I wanted to pass a string from one page
to another, I could do it using the request.

Namely:

<%    // on page x
String foobar = "String to pass.";
request.setAttribute("passedStr", foobar);
%>

<%    // on page y
String foobar2 = (String)request.getAttribute("passedStr");
%>
output: <%= foobar2 %>

However when I try this, the value of foobar2 on page y is _always_ null!

BUT, if instead of request.setAttribute and getAttribute, I use
getServletContext().setAttribute() and getServletContext().getAttribute(),
things work fine!

Why is this, and what's the difference?

The JavaDoc for HttpServletRequest's parent class, ServletRequest says of
setAttribute():

"Stores an attribute in this request. Attributes are reset between
requests."

So what's the point of it?!  What's going on?  Is my understanding of the
request just messed up?!

        Thx in Advance,
        Aurangzeb

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".

Some relevant archives, FAQs and Forums on JSPs can be found at:

 http://java.sun.com/products/jsp
 http://archives.java.sun.com/jsp-interest.html
 http://forums.java.sun.com
 http://www.jspinsider.com

Reply via email to