Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exampples of delete servlets and jsp  RSS feed

 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys I have done out a delete servlet, however I do not know how to carry on in my jsp like when I choose to delete the 1101 record it will delete.

This is my servlet:

Thanks You guys have certainly help me a lot
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sendRedirect is not what you want here.

It sends the 302 status code back to the client which then triggers the redirect on the client side.

If you want to forward processing to a JSP you need to obtain a RequestDispatcher (request.getRequestDispatcher("/file.jsp")) and then forward.
 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry can you explain it more. Cause I dont understand it. Sorry
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
response.sendRedirect sends a response back to the client and tell him to redirect to another page.

The point here is that the request has finished. All data that has been stored in scopes lower than SESSION is lost.

The usual procedure is to forward responsibility to another servlet or in most cases JSP.

It's like saying 'Here JSP, I have done my work and set up all the resources for you to generate a wonderful page for the client, you can carry on from now on).
The client doesn't know about this, it happens on the server side.
 
Loh Peggie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see I see.Thanks
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OTOH a forward won't prevent a refresh of the page trying to do the same delete; that's why the post-redirect-get pattern exists.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!