Thursday, August 1, 2013

Making weblogic server as load balancing webserver


Making weblogic server as load balancing webserver


we can use the weblogic server as webserver by deploying a web application in weblogic server .
web application weblogic.xml and web.xml files should contains the below mentioned tags .
weblogic server details  need to be mention in WebLogicCluster parameter

  <init-param>
      <param-name>WebLogicCluster</param-name>
      <param-value>localhost:7003|localhost:7005</param-value>
    </init-param>


For example if you have one standalone  server and two  servers  in a cluster and Deployed the web application in standalone managed server .

If the request comes to stand alone  server it will send the request to the clustered servers.
weblogic.servlet.proxy.HttpClusterServlet servlet class is responsible to serve the requests.

web.xml
------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
 <servlet>
    <servlet-name>HttpClusterServlet</servlet-name>
    <servlet-class>weblogic.servlet.proxy.HttpClusterServlet</servlet-class>
    <init-param>
      <param-name>WebLogicCluster</param-name>
      <param-value>localhost:7003|localhost:7005</param-value>
    </init-param>
     
  </servlet>
  <servlet-mapping>
    <servlet-name>HttpClusterServlet</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>HttpClusterServlet</servlet-name>
    <url-pattern>*.jsp</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>HttpClusterServlet</servlet-name>
    <url-pattern>*.htm</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>HttpClusterServlet</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>
</web-app>


weblogic.xml file
------------------
<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">
<weblogic-web-app>
    <context-root>/</context-root>
</weblogic-web-app>

No comments:

Post a Comment