Servlet mappings

Your application’s deployment descriptor must specify the servlet mappings for the application’s servlets and JSPs. You can map full paths, partial paths, or file extensions to servlets. Path mappings are specified relative to the application’s context path.

To map request paths to a JSP, the JSP must be defined in EAServer Manager as a Web component. See Chapter 4, “Creating JavaServer Pages,” for more information.

EAServer uses the precedence rules defined in the Servlet 2.4 specification to evaluate each URL:

  1. EAServer checks whether a mapping uses the exact path.

  2. EAServer checks whether a directory in the path is mapped to a servlet, starting at the most deeply nested directory in the path, and working back using the forward-slash character (/) as a separator. For example, if the application’s context path is MyApp and the URL path is MyApp/Accounts/Manage/add.jsp, EAServer checks for servlets mapped to /Accounts/Manage, then /Accounts.

  3. If the last node in the path contains an extension, EAServer checks for a servlet mapped to that file extension. A file extension is defined as the part of the URL that follows a period occurring after the last slash in the URL. For example, in the path MyApp/Accounts/Manage/add.calc, the extension is calc.

  4. If neither of the previous two rules results in a match, EAServer invokes the application’s default servlet if defined. The default servlet is mapped to the path /. If no default servlet is defined, EAServer looks for a static file matching the path.

NoteImplicit JSP mapping The jsp extension is implicitly mapped to invoke EAServer’s JSP engine. You can override this mapping in the explicit mappings for your Web application by mapping *.jsp to a servlet or JSP. However, if you do so, there is no way to invoke the EAServer JSP engine to compile and run arbitrary JSP files. Sybase recommends you not use explicit *.jsp mappings.

Use these rules to format the path specification when editing the servlet name and mapped path:

Here is an example:

<servlet-mapping>
    <servlet-name>delete</servlet-name>
    <url-pattern>/delete</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>edit</servlet-name>
    <url-pattern>/edit</url-pattern>
  </servlet-mapping>
  <servlet-mapping>    <servlet-name>get</servlet-name>
    <url-pattern>/get</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>main</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>