Hi,

I have another very basic question. If it is a problem tell me to leave, sorry. The index.html page has a form which lets users enter a username/password combo, which gets sent to LoginServlet. LoginServlet performs the authentication, and if it fails then the user is redirected to an error page. But if it succeeds, I want to instantiate a UserBean class (which I have created) and make the scope of that bean "session". So that I can access this bean in later pages.

I understand that I can have my JSPs create or refer to a named bean using

<jsp:useBean id="nameOfInstance"
class="UserBean"
scope="session"
/>

This is fine. But I would like to instantiate the bean in LoginServlet. How can I register the bean in the session scope for later JSP's to retrieve it?

My first guess was that in LoginServlet I could call

// "ub" is reference variable of instantiated UserBean
HttpSession session = getServletContext().getSession();
session.setAttribute("nameOfInstance", ub);

But I do not think that this is right. Later JSPs can access this instance of UserBean using id="ub" ????



Thanks,

Erik


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to