• Post Reply Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher.forward() is init()ing servlet?  RSS feed

 
Brian Mulholland
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, we have a weird situation. We have an app that has been in maintenance mode for a long time. A recent change moved some code that was in teh servlet context listener to the servlet init method. The context listener was firing first of course, and the code required some resources that weren't available until servlet init.

Anyway, moving this code caused us to either notice something we never noticed before or cause something. The something is that under some conditions, the servlet init is throwing an exception where the stack trace reveals that it was invoked as a downstream consequence of RequestDispatcher.forward(). This is in an application that already ran the initialization and has load-at-startup on in web.xml.

This baffles me. If you ran init already, why would forward() call init() again?
 
Anurag Verma
Ranch Hand
Posts: 168
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
init is called just once in a servlet life cycle. do you have a call to init method within your code by any chance?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Mulholland wrote: The something is that under some conditions, the servlet init is throwing an exception where the stack trace reveals that it was invoked as a downstream consequence of RequestDispatcher.forward(). This is in an application that already ran the initialization and has load-at-startup on in web.xml.

how you are getting the request and response either in ServletContextListener or init of servlet?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!