• Post Reply 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

update record for selection of id

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had to update the record in the database ,but i am confuse how to do this.
I am getting empid in my servlet page but then i am confuse how to display record on basic of this empid in jsp page. and from there update these record .

My servlet is : UpdateServlet.java



Java page : UserUpdate.java


UserDetails.java
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nitin,

Generally this type of thing is done by considering primary key of perticular table.

While calling any updation or creation method, first we have to check that primary key,
if it is empty then call creation method and
if that key is non-empty then call updation method.

that means when you are getting the data from that table in bean you should get primary key,if you update some data & click on save than due to that primary key updation method is getting called.primary key you can populate in JSP by using hidden form feild.

 
Nitin Belaram
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shail Narkhede wrote:Nitin,

Generally this type of thing is done by considering primary key of perticular table.

While calling any updation or creation method, first we have to check that primary key,
if it is empty then call creation method and
if that key is non-empty then call updation method.

that means when you are getting the data from that table in bean you should get primary key,if you update some data & click on save than due to that primary key updation method is getting called.primary key you can populate in JSP by using hidden form feild.



My empid is primary key and i am getting it value ,Please suggest how to get all row value corresponding to this empid , and how to display them in form for updation
 
Shailesh Narkhede
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are using your custom controller.
If you use Struts for this, their is custom tags available for all these thing.

anyway you can acheive this by,
add getter & setter for each feild in UserUpdate class.

write your jsp with one form tag with action="UpdateServlet"(url pattern in DD of UpdateServlet).
then write text tags with name simillar to name in "UserUpdate" class feild.
due to that while submitting all feild is passed with request as parameter. you can get them by request.getParameter().

Now for displaying data You can use scriptlets in scriptlet you will get "UserUpdate" from session.(which is set in session by getting fron DB before forwarding to jsp)
now in value attribute of text tag write expression there get value from getter of that perticular feild.
actually this is not good solution, but I thing we can do this way.

You can also do this by custom tags for text feild.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic