The moose likes Struts and the fly likes why is my loginForm stopped processing the user input Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Struts
Reply Bookmark "why is my loginForm stopped processing the user input" Watch "why is my loginForm stopped processing the user input" New topic
Author

why is my loginForm stopped processing the user input

kay lin
Ranch Hand

Joined: May 20, 2004
Posts: 132
hi all:
I have written a login page using Struts, basically the loginForm takes the user input at the JSP page and process it

here is a snippet of my JSP code




and here is the code for my LoginForm class


and in my LoginAction class,it tries to get the userId from the form first and then process it...


But when i run this, every time, the print out of user id is "NULL" even if i entered a user id in the form,
it works okay if i use request.getParameter("userID") though

can somebody please tell me what is going on? Many Thanks
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
Hi

The way u r instantiating the form bean is wrong ....saying new LoginForm() will create a new instance which will give u always null.

If u look at the parameters in the execute/perform method the form will give the instance which is populated by struts .so in ur actio u need to just typecast the object by saying

LoginForm loginForm=(LoginForm)form;

Internally whenever a req is fired the insatnce will be populated and that will be populated in the request in the form of req.setAttribute("LoginForm") this is the name waht u have given in ur struts-config and finally this is what u get as parameter ..............-
kay lin
Ranch Hand

Joined: May 20, 2004
Posts: 132
THanks
 
IntelliJ Java IDE
 
subject: why is my loginForm stopped processing the user input
 
Threads others viewed
Form validation in struts
Dynamic Textboxes.
blank page - Action is not called
Not getting bean values inside IE, In firefox working fine
form bean doesn't come into picture

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture