Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

why is my loginForm stopped processing the user input

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic