Forums Register Login

use bean instance in servlet

+Pie Number of slices to send: Send
Hello all,
How to get the bean instance of JSP in servlet?
I have a x.jsp, there are 3 input fields.
I have a xbean.java for the above input form of the x.jsp.
jsp use bean tag is used in this x.jsp. set property * is used to populate all the fields that the user has entered in this input form in the bean(which the jsp engine does).
How to get this xbean instance in the servlet for processing? so that i can call get methods of this xbean to get the user input and process.
Thanks in advance
+Pie Number of slices to send: Send
Hi,
Depending on context of the bean, just retrieve attribute with name same as bean id used in JSP and cast it to the bean class and you are ready to use it.
Bhushan
+Pie Number of slices to send: Send
bean Context...i did not understand.
what is the exact code..??
is it avilable in request object?
+Pie Number of slices to send: Send
The scope of the bean u have declared in the jsp decides how u can fetch it in the servlet.
if the scope is request and the id of bean is "xBean" u can retrive it using
(TypeCast)request.getAttribute("xBean");
or if the scope of bean is session in jsp the same can be retrived from
(TypeCast)session.getAttribute("xBean");
Devesh
I found a beautiful pie. And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1739 times.
Similar Threads
What's the best way to handle multiple Java bean instance in Jsp?
what is the attribute in servlet ?
using model 1 Architecture for inserting row into DB...
Help with jsp beans
Refreshing jsp page
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:58:13.