• 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

servlet(delete)

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I write a report servlets (employee report)
Name SSN Birthdate
Mary 12345789 12/05/1970
... etc
I like to write some delete servlet with checkbox(delete) ,for every row in the table this is to choice for example first, or third employee record to delete.
checkbox Name SSN Birthdate
x Mary --- ------- for example I click the checkbox in this row because I like to delete this Name,SSN,Birthdate.
It's possible somebody to help me to write some code for this problem.
This is for practice , because I study servlets.
Thanks.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes its possible to do that
After you check a name to be deleted from the database you need to click a submit button to invoke a servlet
In the delete servlet read the values from the checkbox which has the 'checked' value as true, I hope it is checked ..Refer HTML read the value from that checkbox in your form and execute appropriate sql statement to delete the chosen record like
Delete from Employee where name='<the value chosen from the checkbox>'
This would be same as deleting mails from your inbox in yahoo or hotmail
Regards
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Janet
Don't know how much this will help you but try it out.

Regards
Suneel
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can run the servlet when you have the connecting servlets ready, else will give you errors as it calls 2 servlets.
One for picking up login information
Two for transfering the control to the Delete option
In the delete servlet you can write the code to receive the list and using StringTokenizer can take the number parse it to an int and check with the record in resultset and delete.
Regards
Suneel
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Suneel Setlur:
[B]Don't know how much this will help you but try it out.

[/B]


A note of warning: with all these static resources sitting there, this servlet is not threadsafe! It should implement SingleThreadModel or your application will collapse in a big heap as soon as it gets a serious load.
- Peter
reply
    Bookmark Topic Watch Topic
  • New Topic