Java servlets support packaging and deploying Web applications. A Web application archive (WAR) file contains all the components of a Web application including servlets, HTML files, JavaServer Pages (JSPs), classes, and other resources. See Chapter 21, “Creating Web Applications,” for more information.
Beginning with EAServer version 5.1, all servlets are
contained in a Web application.Any servlet that you do not explicitly
add to a Web application is added automatically to the EASDefault
Web application—see “The EASDefault Web application”.
EAServer includes a servlet container that provides network services for requests and responses, decodes MIME-based requests, formats MIME-based responses, and manages servlets.
To add servlets to a Web application, copy the servlet class files under %JAGUAR%\Repository\WebApplication\<web-app>\WEB-INF\classes, and use EAServer Manager to add the servlet to your Web application.
Adding a servlet to a Web application
In EAServer Manager, select either Web Applications | <Web application> or Applications | <application> | Web Applications | <Web application>.
Right-click, select New Web Component, and enter the name of the servlet.
Select the servlet, right-click, and select Web Application Component Properties.
Enter values for the servlet properties described in “Configuring servlet properties”.
Mapping a Web application’s servlet to
a URL
In EAServer Manager, select either Web Applications | <Web application> or Applications | <Application> | Web Applications | <Web application>.
Right-click and select Web Application Properties.
Select the Servlet Mapping tab and click Add. A new row is added to the mapping table.
Place the cursor in the Servlet cell and enter the servlet name that displays in EAServer Manager.
Place the cursor in the URL Pattern cell and enter a string to invoke the servlet from an HTTP URL. For example, if the Web application name is WebApp1 and the URL Pattern string for the servlet is /MyServlet, this URL invokes the servlet:
http://host:port/WebApp1/MyServlet
Place the cursor in the Description field and enter a description of the servlet.
Click OK.
Web application servlets have no default URL mappings.
To invoke a servlet, clients must use the path mapped to the servlet
in the Web application properties.
In the normal configuration, you cannot run servlets without using an alias or Web application name in the request URL. You can configure servlets to run with no alias as follows:
Install the servlets of interest in your server’s Installed Servlets folder, as described in “Installing existing servlets into a server”.
Display the Server Properties dialog for your server, then display the Advanced tab.
Search for com.sybase.jaguar.server.servlet.servlet-mapping in the list. If the property is present, highlight it and click Modify. Otherwise, click Add and enter the property name.
For the property value, enter a comma-separated list of entries with this format:
(url-pattern=/pattern,servlet-name=servlet)
Where:
pattern is
the alias to invoke the servlet, for example, MyServlet
.
servlet is the servlet name, as defined in EAServer Manager.
For example, to map MyServlet to the path /myservlet, and HelloServlet to the path /hello, enter this value (on one line):
(url-pattern=/myservlet,servlet-name=MyServlet),(url-pattern=/hello,servlet-name=HelloServlet)
With these settings, HelloServlet can be invoked with this URL:
http://host:port/hello
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |