We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,645 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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

2
Contributors
2
Replies
1 Day
Discussion Span
1 Year Ago
Last Updated
4
Views
Question
Answered
nore
Light Poster
38 posts since Sep 2010
Reputation Points: 10
Solved Threads: 5
Skill Endorsements: 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");

nore
Light Poster
38 posts since Sep 2010
Reputation Points: 10
Solved Threads: 5
Skill Endorsements: 0
Question Self-Answered as of 1 Year Ago

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.

javaAddict
Nearly a Senior Poster
Team Colleague
3,338 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 450
Skill Endorsements: 7

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0580 seconds using 2.64MB