Chapter 23 Creating Java Servlets


Web application support

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 22, "Creating Web Applications" for more information.

EAServer includes a servlet container that provides network services for requests and responses, decodes MIME-based requests, formats MIME-based responses, and manages servlets.

Adding servlets to a Web application

To add servlets to a Web application, copy the servlet class files under %JAGUAR%\Repository\WebApplication\<web-app>\WEB-INF\classes, and use Jaguar Manager to add the servlet to your Web application.

Steps To add a servlet to a Web application:

  1. In Jaguar Manager, select either Web Applications | <Web application> or Applications | <application> | Web Applications | <Web application>.

  2. Right-click and select New Web Component, and enter the name of the servlet.

  3. Select the servlet, right-click, and select Web Application Component Properties.

  4. Enter values for the servlet properties described in "Configuring servlet properties".


Steps To map a Web application's servlet to a URL:

  1. In Jaguar Manager, select either Web Applictions | <Web application> or Applications | <Application> | Web Applications | <Web application>.

  2. Right-click and select Web Application Properties.

  3. Select the Servlet Mapping tab and click Add. A new row is added to the mapping table.

  4. Place the cursor in the Servlet cell and enter the servlet name that displays in Jaguar Manager.

  5. 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


  6. Place the cursor in the Description field and enter a description of the servlet.

  7. Click OK.


Note   Servlets installed in a Web application have no default URL mappings. To invoke a servlet, clients must use the path mapped to the servlet in the Web application properties.

 


Copyright © 2000 Sybase, Inc. All rights reserved.