Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added code tags where needed

...

How to I get Tomcat's version number?

javax.servlet.ServletContext.getServerInfo();

Starting with tomcat 5.0.28 - there is now a version.sh (or version.bat) program in the bin directory. It will print the version number of tomcat to Standard output.

...

How do I set system properties at startup? Set JAVA_OPTS to be something BEFORE calling startup.bat or before calling catalina.bat. (or you can edit those files, but it isn't advised)

Example (windows): SET JAVA_OPTS='-DpropName=propValue'

Example (UNIX): export JAVA_OPTS='-DpropName=propValue'

Wiki Markup
Windows service users - use \[http://web.bvu.edu/staff/david/tcservcfg/ this\]

...

It is not broken, your tag probably is. Many bug reports have been filed about this. Here is the bug report with all the gory details.*

Why do I get java.lang.IllegalStateException ?*

These are the most common reasons how you can get an java.lang.IllegalStateException:

  • Calling setBufferSize and content has been written.
  • The response has been committed and you do any of the following:
    • Calling ServletResponse.reset() or ServletResponse.resetBuffer()
    • Calling either HttpServletResponse.sendError() or HttpServletResponse.sendRedirect().
    • Calling RequestDispatcher.forward() which includes performing a jsp:forward
    • Calling RequestDispatcher.forward() which includes performing a jsp:forward

Remember that if you call forward() or sendRedirect(), any following lines of code will still execute. For example:
{{{
{
...
response.sendRedirect("foo.jsp");
// At this point, you should probably have a return statement otherwise
// the following code will run
System.out.println("After redirect! By the way ...");
System.out.println("Use commons-logging or log4j, not System.out");
System.out.println("System.out is a bad practice!");

...

How do open a file for reading in my webapp?*

Use ServletContext.getResourceAsStream().*

Can I run tomcat with the JRE, or do I need the full JDK?*

...

Wiki Markup
See the \[http://wiki.apache.org/tomcat/FAQ/Logging Logging\] section of the FAQ.*

I'm getting java.lang.ThreadDeath exceptions when reloading my webapp.*

...

  1. Download Tomcat's base and admin webapp distributions (binaries), unzip to a directory of your choice. We'll use c:\temp in this example. 2. Edit c:\temp\server\webapps\admin\WEB-INF\web.xml to remove the JSPC-generated servlet mappings. These are marked in the web.xml file with comments indicating the beginning and end of the JSPC section. You can simply comment out all these servlet-mappping elements. Be careful not to comment out other servlet mappings such as the Struts dispatcher servlet. 3. Open c:\temp\server\webapps\admin\WEB-INF\lib\catalina-admin.jar with a zip file program like WinZip. Remove the files named *_jsp.class, as these are the compiled JSPs. Do not remove the other class files, the ones under the org/apache/ paths. 4. Download a Tomcat source distribution and unzip it to a directory of your choice, but not the same directory that you used above. We'll use c:\src in this example. 5. Copy everything* except''' the WEB-INF/lib directory from c:\src\container\webapps\admin to c:\temp\server\webapps\admin. Now you will have the uncompiled admin webapp JSPs. 6. If you haven't already, define an admin user in %CATALINA_HOME%\conf\tomcat-users.xml. 7. Start Tomcat, navigate to http://localhost:8080 (or your actual server:port if you have modified the default values), and access the admin web application. It will run slower because Tomcat is now compiling the JSPs on-demand the first time you access them, but should otherwise appear normal.