Friday, February 10, 2006

[Struts] Session variable

If you want to store data from the servlet and view this on the jsp, you can
do this by setting the variable in the session variable
this is done with this example code:

// get this session in the servlet
HttpSession session = request.getSession();

// retrieve the generated number, if not running for first time
Object genNumberObj = session.getAttribute("applGeneratedNumber");

// save the number in this session
session.setAttribute("applGeneratedNumber",new Integer(generated));

thanks to:
http://www.exadel.com/tutorial/struts/5.2/guess/strutstutorial-dynaform.html

Found another resource, this explains the use of session, application and request variables:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00001565.htm

No comments: