Creating a JSP or Servlet Source File

JSP and servlet source files are created and managed in the IDE in much the same way as other file types. Note that the filesystem containing existing JSP and servlet files needs to be mounted before you can use it. You also need to create a web module before you execute a JSP or servlet.

To create a JSP or servlet source file:

  1. From the main window, choose File and choose New to display the New Wizard.
    Tip

    Note that you can also create a new JSP or servlet file by right-clicking on a directory within an existing web module, then choosing New and choose JSP & Servlet and choose Servlet from the contextual menu. In this case, the Target Location pane described in step 3 does not appear, because you have already indicated a target location.

  2. In the New Wizard, click the JSP & Servlet template category and choose JSP or Servlet. Click Next.
  3. In the Target Location pane, type the name of your JSP or servlet, and choose the folder, that is, package, of your JSP or servlet file. Do not include a filename extension as this is added automatically when the file is created. Note that servlets should be contained within the WEB-INF/Classes folder. JSP pages are typically contained in the root directory of the web module or folders within the root directory.
    Tip

    If you are creating a servlet, click Next to specify deployment values. Note that re-using an existing servlet name will result in the deployment descriptor (web.xml) pointing to the newly created servlet class rather than to the existing servlet class of the same name.

  4. Click Finish. The JSP or servlet file is created and opened for editing in the IDE Source Editor.

If you create a servlet outside the IDE, it is treated by the IDE as an ordinary Java class. For the servlet features to be available, you must tell the IDE to treat this class as a servlet. From the main menu, choose Tools and choose Mark as Servlet. You should also make sure the servlet class is located within the WEB-INF/Classes folder.

For information on other file management tasks, such as mounting and unmounting filesystems, creating and customizing templates, and searching for files, see "Managing Objects in the IDE" in the Core IDE Help Set.

See also
File Location in a Web Module
Editing a JSP or Servlet Source File
Compiling a JSP Source File
Executing a JSP or Servlet File
Using .dwt Files

Legal Notices