Originally posted by Goldie Hawn:
Hi,
I want to use some of the bean properties I set thru a jsp page in a servlet. Can someone guide how do i do that....
Thanks
If the bean which you have used in the jsp page has its scope set as "session", then in the servlet, extract the same from the session by a session.getValue() or session.getAttribute() whichever holds good. Please note that the bean is created(first time it is accessed in the jsp) and stored in the session with its name being the name attribute you set in the "jsp:usebean" tag.
Lets say that you are using a bean named "Book" and set the name attribute of usebean tag as "book1".
i.e
<jsp:usebean name="book1" class="Book.class" scope="session">
then within the session, this bean is stored with name as "book1". So in order to extract it from session,
Book otherbook = (Book)session.getValue("book1");
Now, you get the bean object from session and can access its properties .
I hope I have answered your question!