Link to home
Start Free TrialLog in
Avatar of VbMonk
VbMonk

asked on

using variables in multiple pages

If I have declared my variables in a page called test1.jsp, I want to print out these variables in a page called test2.jsp. Is this possible? Please help!!
ASKER CERTIFIED SOLUTION
Avatar of ldbkutty
ldbkutty
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kiranhk
kiranhk

you can use request also

in page1.jsp:

<%
   String var = "something";
   request.setAttribute( "theVar", var );
%>

and in other pages you can retrieve it with:

<%=request.getAttribute("theVar")%>

or if you can have hidden field inside the form of your first jsp which will take the from from these defined variables then when the form is posted to the second jsp you will ge able to retrieve the values using
request.getParameter(Nameof your hidden field)
but data stored in "request" will not be available in all pages, its just the sessions taht can do.
>>> I want to print out these variables in a page called test2.jsp
the req is only for printing in the next page!!!!!