Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

alert in servlet with 'Are you sure you want to delete?'

 
lisy jessica
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I want to delete record from oracle db, i need alert message saying 'Are you sure you want to delete?' with yes and no buttons, if yes, the data should delete if no control shd be in the same page(retrieve.jsp). I have no idea how to do this...the previous page is retrieve.jsp which has the data, based on form input with edit and Delete button end of each row, when i click delete it shd alert me....This is my servlet code:

DeleteData.java




Please help me.

Thanks in advance, Lissy
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
In retrieve.jsp itself you can embed the Javascript that will show user the alert message. In the same Javascript function you can check the user response and continue invoking your DeleteData servlet.
There are couple of other things that you can improve even if you are doing example.
1) Do not embed HTML inside the DeleteData. Read about MVC2 and use JSP for that purpose. I guess you are already doing that in retrieve.jsp as you mentioned.
2) Close the database resources in finally block to make sure they are called even if you encounter exception in your code.

Regds,
Amit
 
lisy jessica
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the reply...will try this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic