Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) 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
Posts: 65653
129
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..
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!