Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher

 
nikil shar
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
am writing a servlet which takes an ID as a parameter. am trying to check if the ID is not null or empty before i do anything with it.



the problem is when the "custID" is not passed as a parameter to the servlet it displays the error.jsp page and then continues on to search the db !! i thought after dispatching the request it would exit/stop rather than continuing on to process the rest of the lines in doPost() ??


any help would be much appreciated.

ta.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlets are not magic -- they follow the same rules as any other Java class. So after the call to forward(), control returns to the servlet which continues to execute. Restructure the code accordingly.
 
Leonardo Carreira
Ranch Hand
Posts: 494
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nikil..

the code should be like this :


Thanks..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic