0

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.

2
  • Sorry is just realized i typed wrong...Instead of (row_id) in the statemnt Now i want to pass this variable(row_id), it is (var2).My doubt is while passing value thru URL the snytax is example?varname=constant or somevalue . WHat if instead of constanrt or somevalue i want to pass some variable Commented Aug 14, 2012 at 20:55
  • Sorry i just realized i have made my question so complicated.The jist is ...."Can i pass string var2 from one jsp page through url to another jsp page.If not how can i do it" Commented Aug 14, 2012 at 20:59

1 Answer 1

1

check out how session works

session.setAtribute('var1','value');
String var1=session.getAtribute('var1') ;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.