Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

database and servlets

 
Yell Srik
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i have created a servlet page which contains a HTML form. the form has many fields. once the user enters the values and clicks on a 'save' button, these values are stored in the database.
now i close the browser. after some time, when i open the servlet in the browser, i want the last set of saved values to the shown in the form..
is it possible?? and if yes, how can it be done???

thanks in advance
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Depending on what you mean by "last saved" you can either load the record from the DB with the highest PK (or perhaps a modify timestamp field - if you also want to show last updated, as well as last created), or hold the last saved PK in the user's session and reload it.

If however you are closing the browser (and so ending the session) and you want the last saved to be reshown, you'll need to save the last saved record PK with a user record, if one exists.
 
Yell Srik
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi paul,
thanks for the reply.actually i want the last saved record to be reshown.
can u give me some sort of code snippet to help me proceed further..
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
read about cookies. That's all the hint you should need.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic