I build a web application using jsp. I send parameters from servlet to jsp in get method to display them in jsp page when I request it. the problem is : when I submit the form to servlet and then return to jsp I have to send these parameter with the request. How can I make a stable parameters so, I have to send them once (in get method only) and maintain them in jsp.
Asked
Active
Viewed 613 times
0
-
I can't for life of me understand what you mean. Please elaborate. – BalusC Nov 30 '10 at 01:20
-
I want to maintain the parameter of the last request(from servlet to jsp) in jsp page so, when I send another request (from jsp to servlet) and return back to jsp, I do not lose the last parameters. I use the last parameter to display items in a list so, I want to maintain them in jsp – sahar Dec 01 '10 at 22:43
1 Answers
1
You could access request parameters by ${param}.
<input name="foo" value="${param.foo}">
...
<input type="radio" name="bar" value="a" ${param.bar == 'a' ? 'checked' : ''}>
...
<select name="baz">
<option value="b" ${param.baz == 'b' ? 'selected' : ''}>label</option>
...
<textarea name="boo">${param.boo}</textarea>
This basically prints request.getParameter("foo") as input value. This way the submitted value will be retained in the input elements.
same question here How can I retain HTML form field values in JSP after submitting form to Servlet?
-
I want to maintain the parameters sent from servlet to jsp, not the fields values – sahar Nov 29 '10 at 20:56
-
-
@ Dev developer - first u send parameters form servlet to info , then submit the form from jsp to servlet, so $param will solve ur problem. – palAlaa Nov 29 '10 at 21:05