tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wade Chandler" <>
Subject RE: Running & debugging servlets on Linux
Date Mon, 17 Nov 2003 16:21:53 GMT
Find under logs catalina.out.  You can change the launch script to give
you the output on the command line by removing > catalina.out from the
script, or you can just view the file.  You can also use JDB and attach
to the running process...even remotely and debug your code.


-----Original Message-----
From: Harry Mantheakis [] 
Sent: Monday, November 17, 2003 4:57 AM
To: Tomcat Users List
Subject: Re: Running & debugging servlets on Linux


> 1) Tomcat for Linux does not pop up a new console, like in windows, so

> I cannot watch my debug messages and/or exceptions.
> 2) Servlets that need to write a file, work fine on windows, but 
> cannot write the file on Linux. Permissions etc are ok (root, rw). And

> because of problems 1, I cannot figure out where the problem is.

I do not know how to display a console window in Linux, but you could
write debug messages to the log files.

The Tomcat log files are located in the CONTAINER_HOME/logs directory.

To print out debugging statements in Servlets use the
GenericServlet.log() method. Within HttpServlets all you have to do is
call "log(...)". Here is an example which presupposes it is within a
'catch' block in which an IOException called "exception" has been

    log( "Connection Error" + exception.getMessage() );

To print out debugging statements in JSPs use the ServletContext.log()
method. JSPs automatically inherit a reference to their ServletContext
in the built-in object called "application". All you have to do is call
"application.log(...)" within a Java code block in your JSPs. Hence, the
previous example would be written as follows:

    application.log( "Connection Error" + exception.getMessage() );

With a bit of luck you should be able to open log files in your
favourite text editor and monitor the printouts as they occur. (Try
setting the editor so that it automatically refreshes itself.)


Harry Mantheakis
London, UK

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message