Howto: Servlet debugging for Java

Debugging servlet applications with Elements & Java is simple enough. Follow these steps to get going:

  • Get a Java SDK, preferably 8
  • Get Tomcat ZIP, matching in 32/64 bits of the java sdk from http://tomcat.apache.org/ and extract it somewhere writeable
  • Create a new Java Class Library, set the Output Directory to: C:\path\to\apache-tomcat-8.0.18\webapps\ROOT\WEB-INF\lib
  • Add a reference to C:\path\to\apache-tomcat-8.0.18\lib\servlet-api.jar
  • Add using entries for javax.servlet.http and javax.servlet
  • Create a class descending from HttpServlet
  • Override the methods you want, like doGet (see sample code below)
  • Set C:\path\to\apache-tomcat-8.0.18\bin\catalina.bat as start application, run as the parameter.
  • Edit web.xml in C:\path\to\apache-tomcat-8.0.18\webapps\ROOT\WEB-INF and add:

    <servlet>
        <servlet-name>Test</servlet-name>
        <servlet-class>classlibrary4.MyClass</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Test</servlet-name>
        <url-pattern>/TestPath</url-pattern>
    </servlet-mapping>

Before the closing tag.

The end result should look like:

2 Likes