Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet(delete)

 
janet ilieva
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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.
 
narayan kulkarni
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic