0

Hi,
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.
Thanks

4
Contributors
10
Replies
12
Views
8 Years
Discussion Span
Last Post by jwenting
0

hi there have you tried this:

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

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.

0

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.

0
<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

0

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

0

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.

-1

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">
<form>

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

Comments
JSP is for presentation, servlet is for logic. Servlet is where you should setup connection with DB!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.