0

Hello all!
I want to ask you , how to pass variable, there's the example:

I have variable String X in pageone.jsp then i open a new tab page to pagetwo.jsp (using JavaScript window.open) , Is it possible to use the variable X (from pageone.jsp) in pagetwo.jsp ? Please Explain, thank you verymuch! :)

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by javaAddict
0

i've got the answer, i hope it would be useful :)


Set the varaible into the session in Page1.jsp and access the same in Page2.jsp.
In Page1.jsp
session.setAttribute("X", "value");

In Page2.jsp
String x = session.getAttribute("X");

0

i've got the answer, i hope it would be useful :)


Set the varaible into the session in Page1.jsp and access the same in Page2.jsp.
In Page1.jsp
session.setAttribute("X", "value");

In Page2.jsp
String x = session.getAttribute("X");

Unfortunately that is the wrong way to pass the value. You should never use session to pass values from one jsp to the other.
If you are using window.open, can you post that part of your code so I can suggest a better way.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.