0

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.

sahar
  • 569
  • 7
  • 16
  • 29
  • 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 Answers1

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?

Community
  • 1
  • 1
palAlaa
  • 9,500
  • 33
  • 107
  • 166