Hi,
I am new to JSP/Servlets or I can say new to Java.
I wrote a AForm.html, A.jsp, AHandler.java, ABean.java
user fills in data on AForm.html (it has 2 fields say val1, val2)
these values are passed to AHandler.java as method="GET"
now in AHandler.java i am doing sth like below:
// please ignore syntax...
doGet(req, res){
val1 = req.getParameter("val1");
val2 = req.getParameter("val2");
HttpSession session = request.getSession(true);
//Now instantiate ABean
ABean myBean = new ABean();
//Now populate Bean values
myBean.setVal1(val1);
myBean.setVal2(val2);
//Add the ABean object to the session
session.setAttribute("myBean", myBean);
dispatch(req, res);
}
dispatch(req, res) {
req.getRequestDispatcher("A.jsp").forward(req,res);
}
--------
Now in A.jsp
<jsp:usebean id="myBean" class="packegename.ABean" scope="session" />
<H1>
Value of first variable = <%= myBean.getVal1() %>
Value of second variable = <%= myBean.getVal2() %>
---------
in my A.jsp, i am getting null values for myBean.getVal1 and myBean.getVal2.
May be in A.jsp, it is creating new instance for ABean instead of looking for already created instance.
Can anyone help me out in retrieving the values of already instantiated bean from A.jsp?
Thanks in advance