Hi,

Jay SenSharma

Jay SenSharma

We will see a Demonstration of How we can change the HttpSession Cookie Name of a Web Application from (example: XSESSIONID) to something else like (XYZSESSIONID) using Plan.xml Dynamically…without directly modifying the Deployment Descriptors placed inseide the Archived application Which is already deployed and Running on the Server. It’s called as Hot Updation….It’s Really HOT.

Step1). We will develope a Simple Enterprse Application with a WAR file inside it. In order to do that Just create a Directory where we can place all our Application Files:

Example:  C:JavaTestPlanDemo

Step2). Create a Directory “PlanDemoEAR” inside “C:JavaTestPlanDemo”.

Step3). Inside “C:JavaTestPlanDemoPlanDemoEAR” Create two more Directories “META-INF” and “PlanDemoWEB”.

—————–
Step4). Create web.xml file inside: “C:JavaTestPlanDemoPlanDemoEARPlanDemoWEBWEB-INF” like following

<web-app xmlns=”http://java.sun.com/xml/ns/j2ee“>
</web-app>
—————–

Step5). Create weblogic.xml file inside: “C:JavaTestPlanDemoPlanDemoEARPlanDemoWEBWEB-INF” like following

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<weblogic-web-app xmlns=”http://www.bea.com/ns/weblogic/90“>
<session-descriptor>
<cookie-name>XSESSIONID</cookie-name>
<timeout-secs>900</timeout-secs>
<invalidation-interval-secs>30</invalidation-interval-secs>
</session-descriptor>
</weblogic-web-app>

—————–
Step 6). Provide the Default “index.jsp” welcome page for our WebApplication: in the location: C:JavaTestPlanDemoPlanDemoEARPlanDemoWEBindex.jsp

<center>
<TABLE Border=10%>
<TR><TH>CookieName</TH><TH>CookieValue</TH></TR>
<%
Cookie cookies[]=request.getCookies();
if(cookies!=null)
{
for(int i=0;i<cookies.length;i++)
{
out.println(“<TR><TD>”+cookies[i].getName()+” </TD><TD>”+cookies[i].getValue()+”</TD></TR>”);
}
}
else
out.println(“<h3>Please Refresh The page…”);
%>
</TABLE>
————–
Step 7). Provide “application.xml” file in the location: “C:JavaTestPlanDemoPlanDemoEARMETA-INF” like:

<?xml version=”1.0″ encoding=”UTF-8″?>
<application xmlns=”http://java.sun.com/xml/ns/j2ee” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” version=”1.4″>
<description>Plan Example</description>
<module>
<web>
<web-uri>PlanDemoWEB</web-uri>
<context-root>PlanDemoWEB</context-root>
</web>
</module>
</application>
————–
Step8). Deploy the EAR file “PlanDemoEAR” in Exploded format or you can even create an EAR from it… “C:JavaTestPlanDemoPlanDemoEAR” to the Desired WebLogic Server.

Step 9). Now access the “index.jsp” Page of your Application. Note: First time this page will display an empty table in the WebPage…You need to referesh the Page sothat it will display the Table like below:

Step10). Now We want to Update the HttpSession Cookie Name from “XSESSIONID” to “XYZSESSIONID” …in order to do that we need to Provide the “plan.xml” file…

Step 11). open a comand window and then run the “setDomainEnv.cmd” or “setWLSEnv.cmd” in it.

Step 12). Now move to “C:JavaTestPlanDemo”  in the Command Window and then run
C:JavaTestPlanDemo>java weblogic.PlanGenerator -all PlanDemoEAR
You will see the Similar Following Output:—->
Generating plan for application PlanDemoEAR
Export option is: all
Exporting properties…
Saving plan to C:JavaTestPlanDemoplan.xml…
<Dec 16, 2009 11:51:24 AM IST> <Info> <J2EE Deployment SPI> <BEA-260072> <Saved configuration for application, PlanDemoEAR>
————————

Step 13). Modify this Plan.xml file like following sothat we can change only the “Session-Descriptor/Cookie-name” element

<?xml version=’1.0′ encoding=’UTF-8′?>
<deployment-plan xmlns=”http://www.bea.com/ns/weblogic/deployment-plan” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://www.bea.com/ns/weblogic/deployment-plan http://www.bea.com/ns/weblogic/deployment-plan/1.0/deployment-plan.xsd” global-variables=”false”>
<application-name>PlanDemoEAR</application-name>

<variable-definition>
<variable>
<name>NewCookieName</name>
<value>XYZSESSIONID</value>
</variable>
</variable-definition>

<module-override>
<module-name>PlanDemoWEB</module-name>
<module-type>war</module-type>
<module-descriptor external=”false”>
<root-element>weblogic-web-app</root-element>
<uri>WEB-INF/weblogic.xml</uri>
<variable-assignment>
<name>NewCookieName</name>
<xpath>/weblogic-web-app/session-descriptor/cookie-name</xpath>
</variable-assignment>
</module-descriptor>
</module-override>

<config-root>C:DOCUME~1JAYKUM~1LOCALS~1Tempjaykumars.configdeploymentsPlanDemoEARplan</config-root>
</deployment-plan>
—————-
Step 14). Now Login to admin Console and then Click on “Lock and edit” Button From Deployment Platte select(Check) your Desired Application “PlanDemoEAR” and then Clieck on “Update” Button…While Updating the Application it will ask for the New “Plan.xml” file Location Just browse to “C:JavaTestPlanDemoplan.xml” and then click on “Next”—>”Finish”. Save the Changes.

Step 15). Now once again Access the “index.jsp” page…Now you will see that the Cookie Name is Changed to “XYZSESSIONID”

.

.

Thanks
Jay SenSharma