Running a JSP or Servlet File

As with other files, it's easy to run JSP files during the development cycle. If the JSP file has not been compiled, or if it has changed since it was last compiled, the IDE automatically compiles the file before running it. If the web server and web browser have not been started, the IDE automatically starts it. (If your default server is set to something other than the Tomcat server, this behavior might vary.)

To run a JSP file:

  1. In the Explorer, click the Filesystems tab and select your JSP file.
  2. From the main menu bar, choose Build Execute.

    If there are no errors, you are switched to the running workspace and the output from the compiled JSP page is displayed in the web browser.

You don't need to restart the server to pick up changes in the JSP or servlet file. However, you need to restart the server if there are changes you want to pick up in components referenced by the JSP (such as JavaBeans components or error pages). In those cases, simply right-click the JSP or servlet file and choose "Execute (Force Reload)" from the contextual menu.

To run a servlet file:

  1. Install the Advanced JSP & Servlet module in your version of the IDE.
  2. In general, you can map one servlet class to many logical servlets in the web.xml file. (They can have different set of init parameters). Each of these logical servlets can have more servlet mappings including mappings like /path_to_servlet/*.
  3. When you are executing the Java servlet, specify which URI should be used to activate servlet execution.
  4. From the servlet's contextual menu, choose the Properties item, and click the ellipsis button to display the URI Property Editor.
  5. Type in the desired URI and click OK>
If you create a new servlet from the New From Template wizard, the IDE writes some default values into the web.xml file and sets the URI property to match to this mapping. But if the servlet is converted from any other class, the IDE does not specify the URI, and asks you to specify the URI before the execution of the servlet. The Tomcat server provides a servlet interceptor that enables you to execute your servlet class without having it specified in a web.xml file. The servlet interceptor provides a default mapping as follows: /servlet/your.package.YourServlet
See also
Creating a JSP or Servlet File Editing a JSP or Servlet File
Compiling a JSP Source File

Legal Notices