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“>

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“>

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

<TABLE Border=10%>
Cookie cookies[]=request.getCookies();
for(int i=0;i<cookies.length;i++)
out.println(“<TR><TD>”+cookies[i].getName()+” </TD><TD>”+cookies[i].getValue()+”</TD></TR>”);
out.println(“<h3>Please Refresh The page…”);
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>
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”>


<module-descriptor external=”false”>

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”



Jay SenSharma

If you enjoyed this post, please considerleaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.