Sankalp
Sankalp

Reputation: 173

How to Pass Variable and not values in URL in jsp page

I have a String called var2="ASDFDE" whose value keeps changing. Now I want to pass this variable(row_id) in URL. For that I may need to write

action=action.jsp?var1=var2

In the action jsp page when I retrieve the row

out.println("Row_ID from previous jsp page is: "+request.getParameter("var1"));

It prints out

Row_ID from previous jsp page is: var2 whereas what I want is Row_ID from previous jsp page is: ASDFDE

How do I do that? How do I just pass the variable through the URL without mentioning its value so that whatever would be the current value of that String is passed to next jsp page.

If it cannot be done through URL then what is the alternative. It would be really helpful if someone can explain with the example, I am new to this.

Upvotes: 0

Views: 4359

Answers (1)

MaVRoSCy
MaVRoSCy

Reputation: 17859

check out how session works

session.setAtribute('var1','value');
String var1=session.getAtribute('var1') ;

Upvotes: 1

Related Questions