It is possible to execute and debug servlets from within NetBeans. This is done by using the internal Tomcat server that comes with NetBeans. In order to allow unregistered servlets to run, you should modify web.xml and server.xml in the conf directory.
In NetBeans, Tomcat is set up in a multi-user format. Your conf, logs, and
webapps directories are located under
C:\Documents and Settings\your
userid\.netbeans\3.6\jakarta-tomcat-5.0.19_base
This is the location of the conf directory where you will find the web.xml and server.xml files for your deployment of Tomcat.
I recommend that you declare the Invoker Servlet in the web.xml
file that is located in the conf directory. The following code should
be placed after the servlet tags for the default servlet.
<servlet> <servlet-name>invoker</servlet-name> <servlet-class>org.apache.catalina.servlets.InvokerServlet</servlet-class> <init-param> <param-name>debug</param-name> <param-value>0</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet>
I also recommend that you enable servlet mapping throughout your
deployment. Add the following code where all the other servlet mappings
are located in the web.xml file. Place this after the servlet
mapping for the default servlet.
<servlet-mapping> <servlet-name>invoker</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping>
Create a context and mount this file system in NetBeans.
Add the context to the internal Tomcat of NetBeans
Be sure that the context is reloadable
reloadable="true"
When you execute a servlet in NetBeans, it will try to start the internal
Tomcat. Since Tomcat is running inside of NetBeans, you will be able to set
breakpoints in the code and stop execution of the servlet. You will still
use the browser to interact with the servlet, but control will return to
NetBeans when a breakpoint is encountered.
If you get the error
No web modules in repository
then you did not add the context correctly. See the instructions on Mounting a File System and Adding a Context.