I wish to save value entered by user in textbox in a session variable.my form contains many elements and i need to navigate back and forth.so i want to save the value once entered by the user in a session variable so that i can retrieve it and display on navigating back.i know session.setAttribute("varname",stringvalue);
saves stringvalue in varname but how do i get textbox value as a string on the page and save it there?request.getParameter does not work on the same page.

hi there have you tried this:

<%session.setAttribute("[I]varname[/I]", request.getParameter([I]Textboxname[/I]));%>

request.getParameter works just fine. You shouldn't use it of course as you should NEVER use any Java code on a JSP, but it does work.

I am quite new to JSP JWenting, I am intrigued, why is java code on JSP frowned upon?

JSPs are for presentation purposes only, not processing data.
They're also designed to be able to be maintained by non-programmers, people who don't know Java.
So they get presented with a set of tags (JSTL for example) that looks familiar to them.

ohh right, thanks for that will bear that in mind!

<input type="textbox" name="AQC2_SOURCE_FILENAME" value=""  />

<%session.setAttribute("srcfilename", request.getParameter("AQC2_SOURCE_FILENAME")); 
String str=(String)session.getAttribute("srcfilename");
System.out.println("file name is***** "+str);

the code above gives str value as null.

what else can i do so that textbox value once entered remains after navigation as well.thanks

have you even bothered to read the entire thread?
Probably not, as you'd have learned not to do what you suggested.

I'm sorry for that but was just trying to say that it does not work.Also if you bother to read the entire thread I last posted then you'd see that I did ask for a different way to solve the problem.

I have used this code in my project

page name is abc.jsp

 session.setAttribute("srcfilename", request.getParameter("AQC2_SOURCE_FILENAME")); 
		String str=(String)session.getAttribute("srcfilename");

<form name-"abc" action ="abc.jsp">
<input type= "textbox" name="AQC2_SOURCE_FILENAME" size="20" value="">
<input type= "textbox" name="new textbox" size="20" value="<%=str %>">
<input type= "submit" name="Submit" size="20">

Sorry I haven't use System.out.println
Hope it help u

commented: JSP is for presentation, servlet is for logic. Servlet is where you should setup connection with DB! -1