Moving Variable from one form to the next

My 2 forms (one with a submit button) work well in passing values of variables in one page to the next. Page1.jsp has input text controls and Page2.jsp does not have form controls. In this situation, I can play around with variables obtained from page1.jsp in page2.jsp.

I decided to put a form button control and one input text control in page2.jsp. What now happens is that I can get the variables from page1 but when I click the submit button I included in page2.jsp, the values of the variables turn to 'null'. I have verified this using out.println statements. my code is as follows:
String Page1Input = request.getParameter("Index");
out.println(Page1Input); //produces the results but when button is clicked, it turns to 'null'

I want to use Page1Input in the code when button in page2.jsp is clicked. It seems like the submit button refreshes page2.jsp so that I lose the obtained data.
How can I resolve this??
Please help!!!!!!!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Each page submit/click is a new request, so parameters in request can't pass across multiple pages.

You either put hidden field in page2.jsp to store the value from page1.jsp or store the value from page1.jsp in HttpSession and use session to carried the value across multiple pages.

Boon Leng

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Yes. Using session to keep variable along multiple pages.

Here are some useful code.

//To put variable to session
String temp = "Hello World";
session.setAttribute("name", temp);

//To get variable from session
String str = (String)session.getAttribute("name");

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.