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:
EAServer checks whether a mapping uses the exact path.
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.
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.
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.
Implicit 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:
All mappings are relative to the Web application’s root request directory.
To map a directory, enter a path that ends in a “*”,
for example /foo/*
or /foo/stuff/*
.
To map an extension, enter *.ext
,
where ext is the extension.
To specify a default servlet for the application,
enter the path as a single forward slash (/
).
To specify an exact match, enter the full path relative to the Web application’s root request directory.
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>