Hi,
Sorry, if you receive this mail again. I am sending this mail again as i got "mail
failed, returned to sender" message.
I have tested the Bean with lifespan="page" and "application". It is working as
expected.
But, i am not satisfied with the output of the lifespan="session".
I will explain the flow :
ENTRY.JSP is the JSP program in which i am declaring the Bean with lifespan="session"
SetonCreate value is set to "INIT-NAME" for the property BEANPROPERTY="userid"
Then i am calling a method in the Bean which replaces the value from "INIT-NAME" to
"NEW NAME"
Then from ENTRY.JSP i have an hyperlink which will take me to Response.jsp.
In RESPONSE.JSP i am declaring the same Bean with lifespan="session"
SetonCreate value is set to "INIT-NEW-NAME" for the property BEANPROPERTY="userid"
Then i am displaying "userid" property.
It is still showing "INIT-NAME" and not "NEW NAME".
My Conclusion
---------------------
The Bean is not recreated in Response.jsp. Otherwise, it would have printed
"INIT-NEW-NAME".
So, it is very clear that the Bean does not get recreated. But, why it is still have
"INIT-NAME" instead of "NEW NAME" ?
I printed the output. It is as follows :
In ENTRY.JSP it is INIT-NAME and then changed to NEW NAME
But in RESPONSE.JSP it is still INIT-NAME.
I am enclosing the code along with this. It will be great if you can clear my doubts
in this.
CODE
=====
ENTRY.JSP
------------------
<%@ errorpage="error.jsp" %>
<html>
<HEAD><TITLE> TESTING </TITLE></HEAD>
<BODY>
<USEBEAN NAME="beanId" TYPE="JSP_JAVABEAN.BeanTest" LIFESPAN="application" >
<SETONCREATE BEANPROPERTY="userid" VALUE="INIT-NAME">
<SETFROMREQUEST BEANPROPERTY="*">
</USEBEAN>
<%
HttpSession hs = request.getSession(true);
out.println("Creating new session: "+hs);
%>
<h1> USER_ID-1 is : <DISPLAY PROPERTY="beanId:userid"></h1>
<%
beanId.setnew();
%>
<h1> USER_ID-2 is : <DISPLAY PROPERTY="beanId:userid"></h1>
<a href=http://3.209.128.129:80/NASApp/JSP_JAVABEAN/Response.jsp> CLICK </a>
</BODY>
</html>
RESPONSE.JSP
-------------------------
<%@ errorpage="error.jsp" %>
<HTML><HEAD><TITLE>Title</TITLE></HEAD>
<BODY bgcolor="#FFFFFF" text="#000000" link="#CC0000" vlink="#FF3300"
alink="#003366"><P> </P>
<USEBEAN NAME="beanId" TYPE="JSP_JAVABEAN.BeanTest" LIFESPAN="application" >
<SETONCREATE BEANPROPERTY="userid" VALUE="INIT-NEW-NAME">
<SETFROMREQUEST BEANPROPERTY="*">
</USEBEAN>
<h1> USER_ID-1 is : <DISPLAY PROPERTY="beanId:userid"></h1>
</BODY>
</HTML>
BEANTEST.JAVA
---------------------------
package JSP_JAVABEAN;
import java.util.*;
import java.lang.reflect.*;
import java.io.*;
public class BeanTest implements Serializable
{
String userid;
public BeanTest()
{
System.out.println("Constructed Hari Bean");
userid = null;
}
public void setUserid( String name )
{
userid = name;
System.out.println(" Set Name is : " + userid);
}
public String getUserid()
{
System.out.println(" Getter is : " + userid);
return userid;
}
public String setnew()
{
userid = "NEW NAME";
return userid;
}
}
Please, let me know whether my understanding regarding Bean with lifespan="session" is
correct or not.
If it is correct, then why the output is "INIT-NAME" instead of "NEW NAME".
Thanks in advance... R. Bala
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets