I read in another post by William Brogden that there's only one instance of a servlet, not one per user session like with beans. Maybe I read that wrong, but if that's true, how do I access user info from that servlet? For example, I've got a form that submits to a JSP, and the JSP can use the usebean tag and pull info from the user's account info bean to find out what info the user has access to. I'm trying to convert that form to post to a servlet instead, but in that servlet, I no longer have access to the user's account info bean, and I wouldn't want to just trust the request parameters, because someone may be trying to fool the system into giving them someone else's information...
Given: A servlet may have many sessions, a session may have many requests and a user may have one session ( okay, they may be using multiple browsers and have multiple sessions, but only if you let them log in more than once) then if you store the userbean in the session, you'll have access to it from your servlet for the life of the session.
Joined: Jul 15, 2003
So, how do you access those beans from servlets? Is there something like a JSP's usebean tag for servlets?
Why not look at the JavaDocs for HttpSession in the javax.servlet.http package? Or maybe buy a good book on servlets or find a tutorial. Hint - the javabean object will be in the session under the name used in the JSP. Take a look at the servlet code produced by the JSP compiler to see where it happens. It really doesn't make any sense to try to pick up your knowledge of servlets one question at a time when all these great resources exist. Bill [ February 18, 2004: Message edited by: William Brogden ]