Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirecting in servlets

 
zel hatake
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, I'm having problems with my redirection code for a java servlet code.

When a user clicks the Register button...
>the /regisration_page servlet will be shown wherein it have requestDispatchers composed of 3 fragments (banner.jsp,footer.jsp,content.jsp)
>the content.jsp contains the <form action="/register" method="POST"> when the user finishes filling up the necessary information, the servlet /register will then insert the data into the database.. well it work fine..
>but then i need to redirect the user to a page that will notify him if the registration is successful.

I tried the following...

In the /register servlet I inserted the ff in the doPost:



and I created a new fragment named registrationStatus.jsp that will get the parameter



And then how will I show the page to my user?
I thought of using the processRequest in the /register servlet wherein I used the RequestDispatcher to combine 3 jsp fragments and send it back to the client:



And its not working... I don't know what I did wrong.. is there something wrong with my logic???
Help will be much greatly appreciated. Thank you!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, but I cannot get past this:
You realize that this will completely mask any exceptions that are thrown?
 
Prasad Krishnegowda
Ranch Hand
Posts: 670
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java exception messages are written in a way, so that it will be easy to debug the problem and by having a empty catch block, you are not helping yourselves and is a very poor thing to do.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic