Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

saving an input element state(value)

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
hi,

i wrote a jsp file which has a form and some input elements, after a form submitting to servlet, the servlet forward back to the jsp but the input elements does

not keep their values has it were before submitting. my question is how to keep the values of the input elements like they were before the submitting?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
If your servlet just returns to jsp file simply, you can use <%= request.getParameter("name") %> or one different option is save variables' values into session object and get them from session object in jsp page.
 
moshik salem
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
i am trying to post a form to the servlet using javascript, the servlet is forwards back to the same jsp. but because the javascript the form is submitted again

and the same servlet is forwards back again, and this process occur over and over again.

i tried to stop this behavior with hidden field that acts like a flag but his value is lost after the servlet forwards back.

what to do to solve this problem?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi ,

Normally what i used to do is

page1.jsp

some javascript code to submit to "MyServlet"
......
<form>
name
<%
String var1=request.getParameter("uid");
if(var1==null)
var1="";

out.println("<input type=text value="+var1+" name=uid>");

%>
</form>

considering that servlet forward like this
MyServler
RequestDispacther rd = request.getRequestDispatcher("page1.jsp");
rd.forward(request,response)


If still problem not slove post the demo code
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Sounds a lot like your other post where things aren't working as they should be. Your script must be dining something rather hanky, but you haven't posted it in wither topic.

I'm going to close this topic so we can concentrate on the other one where you should post your script (be sure to UseCodeTags).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic