I am trying to debug a java web application. The problem is due to something before the doGet/doPOST methods. Where do I start where do I look inside the container to debug before the doGet or how exactly is a request handled?
-
AFAIK you servlet life cycle is init -> doGet/doPost --> destroy you can see in init before getting executed doGet/doPost...Ramesh Kotha– Ramesh Kotha2012-04-23 20:10:54 +00:00Commented Apr 23, 2012 at 20:10
-
You can attach a debugger to your container and tell it to pause on error.hvgotcodes– hvgotcodes2012-04-23 20:11:54 +00:00Commented Apr 23, 2012 at 20:11
-
what do you use for developing (which IDE/editor?)Tor P– Tor P2012-04-23 20:12:57 +00:00Commented Apr 23, 2012 at 20:12
-
Post the problem you are facing.kosa– kosa2012-04-23 20:13:53 +00:00Commented Apr 23, 2012 at 20:13
-
The problem I think is due to stuff in the web.xml eg authentication at the container level, how can this be debugged I am using eclipse.Paul– Paul2012-04-23 20:18:21 +00:00Commented Apr 23, 2012 at 20:18
2 Answers
Here is the Servlet lift cycle.
Intit
Service(doGet/doPost)
Destroy
When servlet initialized init method calls so you can start debugging from the init method of the servlet and moves towards Service(doGet/doPost) method. see Servlet Life Cycle
Comments
Well, the answer depends greatly on what you load before the doGet/doPost parts of your code. Do you set up code in contextListeners, if so you start there, etc...
To better debug you should enable logging to file in the servlet container (i.e. jetty, tomcat, glassfish, whatever) to see if there is any error messages there that might be the cause of your woes...