Kumar Shroff

Greenhorn
+ Follow
since Dec 05, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kumar Shroff

i did check using val1 = <%= request.getParameter("val1") %>
and it works (val1 is not null). But my requirement is to use <jsp:usebean /> and retrieve the value.

setVal1 and setVal2 are just setter methods in ABean.java.
and Iam using method = "GET" not post.

I would appreciate if anyone can help me out in retrieving the values from <jsp:usebean />

thanks
18 years ago
JSP
request or session does'nt anything would do for me.
I just wanted to know how to retrieve already instantiated bean (instantiated in a servlet) from JSP file
18 years ago
JSP
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
18 years ago
JSP