File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes having trouble debugging Servlet!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "having trouble debugging Servlet!!" Watch "having trouble debugging Servlet!!" New topic
Author

having trouble debugging Servlet!!

Michael Morella
Greenhorn

Joined: Nov 22, 2003
Posts: 2
I am having trouble debugging my servlet because I cannot find out where to put some statements to view variables at different times.
When I debug my applications I can at least use System.out.println statements and view the output. I do not understand what to do with the servlet. Is there somewhere in Tomcat that the output is posted or is there another way to send variable values to a place that I can view it?. I tried to write them to a file but I keep getting errors:
java.lang.NullPointerException
at java.io.DataOutputStream.writeBytes(DataOutputStream.java:252)
at coreservlets.SortParams.(SortParams.java:54)
at coreservlets.WheelFormProcess.doGet(WheelFormProcess.java:31)
at coreservlets.WheelFormProcess.doPost(WheelFormProcess.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:466)
at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:216)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at filters.ExampleFilter.doFilter(ExampleFilter.java:149)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:534)
Hope this is clear enough
Thanks for any help.
Joe Pluta
Ranch Hand

Joined: Jun 23, 2003
Posts: 1376
Take a look at the batch file that starts up Tomcat. That should tell you where your logs are going. As far as I know, System.out.println() still goes to stdout, and you just have to redirect it properly if you want a log file.
There are also other logs available in the /logs folder of your Tomcat installation.
Joe
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
if your running tomcat on windows when you launch it by hand (ie not as a service) you will get a command line window and when you use system.out they go there


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Michael Morella
Greenhorn

Joined: Nov 22, 2003
Posts: 2
I am running the server on Red Hat 8.0 and so i will have to look into the log files.
The problem that I am having is that I have a servlet the takes parameters from a form and I want to put them into a hashtable. That seems to work fine but when I try to extract those values and email them to myself It does not work.
The rest of the code executes fine but that part of it creating a class instance that will handle the request info does not complete. Any insite will be appreciated.
Thank You for your help
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17258
    
    6

"mi-xx-nc"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

is there another way to send variable values to a place that I can view it?

Depends on what you mean by "view".

If you want to view them on a webpage, then this is what Servlets/JSP was *meant* for. So yes, there's definately a way. Just check out any 'hello world' servlet tutorial.

If you mean 'stuff these somewhere so I can view them from a file, command line, or through some other process'... there are a multitude of ways.

Use log4j (a logging package that lets you log debug/info/warning messages)
Use system.out.println (which Tomcat will place in one of several places, depending on your OS and startup method).
Write to a file.
Send yourself an email.

you imply you're doing the last two:
That seems to work fine but when I try to extract those values and email them to myself It does not work.

What doesn't work?? It blows up at this point? The email 'seems' to work, but you don't receive it?

The rest of the code executes fine but that part of it creating a class instance that will handle the request info does not complete. Any insite will be appreciated.

What is the context of the stacktrace? What lines of code lead up to it?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: having trouble debugging Servlet!!