Using beans with my jsp

I have tottally changed my approach for this jsp/servlet project, and i am now using beans and the MVC architecture. SO i am trying to login a user when they enter their username and password, and click login. My main class, which acts as my controller, is like so

So it basically request the parameters and sets them into my bean, and then forwards it to logUser.jsp. My bean is looking like so

Its the getLogin method in their i need to invoke, but i am having problems in my jsp on how to invoke it through a bean. This is my jsp as far

So i request the bean in this jsp, but then how would i invoke the getLogin method in my bean class, with the two current set variables (userName, passWord) of the bean?
any advise would save a life (atleast my poetry is getting better)
cheers

Why are you delaying work until it gets to the JSP? You already have a page controller (research better naming than "main", and what's with the messy "mywork" stuff?) -- your work should be done there. The JSP should be to construct the view only.

I was thinking to change the names of my files, will do that. You say that a jsp is just to construct a view, and i can understand that for what i am doing at the moment. But the reason i am working with beans is because afterwards i will be doing searches in my database and outputting the results to the jsp to be displayed in a table. This means that surely i would have to mix jsp with my java beans?

No, it does not. All work should be done in controllers and the results passed (in beans or other constructs) to the JSP as read-only data.

All data processing should be completed before the JSP is invoked.

Nick Price
Greenhorn

Joined: Jan 03, 2009
Posts: 25

posted Jan 03, 2009 21:25:28

0

So in regards to this, i am trying to add somthing like this to my controller to log someone in

The problem then is, 2 will always be returned as i am using the bean to set the username and password for a specific person, but then i am just calling up the getLogin method through an instance, which doesnt relate to whats been inserted as the username and login. I would be better off just doing somthing like
String username = request.getParameter("userName")); and then pass these variables to the method. I was just thinking it might be better to use beans.