Referencing a Servlet in a Web Application URL Pattern Matching

9-18 Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server

9.12 Clustering Servlets

Clustering servlets provides failover and load balancing benefits. To deploy a servlet in a WebLogic Server cluster, deploy the Web application containing the servlet on all servers in the cluster. For information on requirements for clustering servlets, and to understand the connection and failover processes for requests that are routed to clustered servlets, see Replication and Failover for Servlets and JSPs in Using Clusters for Oracle WebLogic Server. For information on the load balancing support that a WebLogic Server cluster provides for servlets, and for related planning and configuration considerations for architects and administrators, see Load Balancing for Servlets and JSPs in Using Clusters for Oracle WebLogic Server.

9.13 Referencing a Servlet in a Web Application

The URL used to reference a servlet in a Web application is constructed as follows: http:myHostName:portmyContextPathmyRequestmyRequestParameters The components of this URL are defined as follows: ■ myHostName—The DNS name mapped to the Web Server defined in the WebLogic Server Administration Console. This portion of the URL can be replaced with host:port, where host is the name of the machine running WebLogic Server and port is the port at which WebLogic Server is listening for requests. ■ port—The port at which WebLogic Server is listening for requests. The servlet can communicate with the proxy only through the listenPort on the Server MBean and the SSL MBean. ■ myContextPath—The name of the context root which is specified in the weblogic.xml file, or the URI of the Web module which is specified in the config.xml file. ■ myRequest—The name of the servlet as defined in the web.xml file. ■ myRequestParameters—Optional HTTP request parameters encoded in the URL, which can be read by an HTTP servlet.

9.14 URL Pattern Matching

WebLogic Server provides the user with the ability to implement a URL matching utility which does not conform to the J2EE rules for matching. The utility must be configured in the weblogic.xml deployment descriptor rather than the web.xml deployment descriptor used for the configuration of the default implementation of URLMatchMap. To be used with WebLogic Server, the URL matching utility must implement the following interface: Note: Automatic failover for servlets requires that the servlet session state be replicated in memory. For instructions, see Configure In-Memory HTTP Replication in Using Clusters for Oracle WebLogic Server. Servlet Programming Tasks 9-19 Package weblogic.servlet.utils; public interface URLMapping { public void putString pattern, Object value; public Object getString uri; public void removeString pattern public void setDefaultObject defaultObject; public Object getDefault; public void setCaseInsensitiveboolean ci; public boolean isCaseInsensitive; public int size; public Object[] values; public String[] keys; }

9.15 The SimpleApacheURLMatchMap Utility