the "easy" tag way in jsp is very fun , but when going back to same old java classes (servlets) we have to use the whole method routine.
Now if I may add a follow up... In the JSP, after going through a couple of pages that populate the fields of the bean, I arrive at the final page. How do I get the now-full bean into the session object? What do I pass in to the setAttribute method? Code sample to follow...
(The bean is already established with session scope, so I don't have to useBean it)
the minute you set up the bean with the useBean tag it goes to the scope you mentioned - in this case the session!
it does the setAttribute thing itself (thats how it passes the bean all the time between the jsp pages).
so its even easier than you thought.
YourBean bean = (YourBean) request.getAttribute("bean-id");
YourBean bean = (YourBean) session.getAttribute("bean-id");
YourBean bean = (YourBean) application.getAttribute("bean-id");
Originally posted by Andrew Sweeney:
If I am using a bean within a JSP (with a <jsp:useBean> , how can I get access to said bean within a servlet that the JSP posts to?
(I'm thinking that setAttribute() get Attribute() will work, but I was hoping for something a little more elegant...)
Thanks to all for your advice!