You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by John Cleber Jaraceski <jo...@kolnet.com.br> on 2002/10/22 21:09:18 UTC

Session attributes doesn't work

Hi,

I've done a JspTestCase with 2 tests (testT1 and testT2, see below).

And the testT1 I´ve set the session attribute "name" in my JSP page, but in
testT2 this attribute doens't exists.

I wan't use the beginT1 or beginT2 to set session attribute "name". Because
I have a lot of JSP (and Servlets) that set session attributes.

How can I do the session attributes to work correctly?


public void testT1() throws Exception {
  ...
  pageContext.forward( "/login.jsp");
  ...
}

public void testT2() throws Exception {
  ...
  pageContext.forward( "/home.jsp?name=" + (String)
pageContext.getAttribute( "name", pageContext.SESSION_SCOPE ) );
  ...
}

login.jsp (or Servlet, for example, with this code):
... <% pageContext.setAttribute( "name", "John",
pageContext.SESSION_SCOPE ); %> ...

home.jsp (or Servlet, for example, with this code):
... Hello, <%= (String) pageContext.getAttribute( "name",
pageContext.SESSION_SCOPE ); %> ...


Thanks.

P.S.: Sorry, but my english is not very well...

John Cleber Jaraceski
Sun Certified Java 2 Programmer
john@kolnet.com.br


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>