tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phuc Truong" <ptru...@experience.com>
Subject RE: How can I have two beans in the same JSP?
Date Wed, 23 Aug 2000 03:27:46 GMT
Two ways I can think of, the first way is better if you have a non-java.lang
object that can't be parsed back from a string:

1. add the value to the session on page 1:
	session.put("value", foo)

on then page2 get the value:
	foo = (FooClass) session.get("value");
	session.remove("value");

2. passing the value as a cgi parameter:
	response.sendRedirect("page2.jsp?value=foo");

on page 2:
	String foo = request.getParameter("value");
	Integer foo = new Integer(request.getParameter("value"));

-Phuc

-----Original Message-----
From: Rui Oliveira [mailto:oliveira@milu.ipn.pt]
Sent: Tuesday, August 22, 2000 6:01 PM
To: tomcat-user@jakarta.apache.org
Subject: How can I have two beans in the same JSP?


Hello,

I have 2 JSPS and I want to get a variable from one to the other.

Lets say that I have a page called "page1.jsp" and that I have a
"bean_A" in this page. One of the methods from that bean returns a value
that I must use in the next JSP, lets call it "page2.jsp".

My question is: do I need to open the first bean (bean_A) in the second
page (page2.jsp), in order to get the value from that bean? If so, how
can I keep the state of that bean, so that it wont lose its value from
page1.jsp to page2.jsp?


Thx

Rui


Mime
View raw message