954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Pass Value from .jsp to new page .jsp

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! :)

nore
Light Poster
38 posts since Sep 2010
Reputation Points: 10
Solved Threads: 5
 

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");

nore
Light Poster
38 posts since Sep 2010
Reputation Points: 10
Solved Threads: 5
 

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 thewrong 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.

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You