• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Recieving 'null' values from a jsp page in Struts2 Action

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all, I'm using Struts2+JSP as my J2EE framework. Sometimes I Strangely get null values from the struts text fields of my jsp page into actions! for example in the login page, despite of validating my forms and preventing from entering invalid data such as null or blank, I still get null value for the username field instead of the actual entered value. has anyone come across such an occasion?

here is a piece of code in which this error happens:

the respective JSP form


JavaScript Validator:



I'm extremely astonishingly confused on this! Any ideas?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are no getters or setters in LoginAction?
 
Jalal Jafari
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:There are no getters or setters in LoginAction?


well there must be getters and setters to make Struts work.

 
Ranch Hand
Posts: 349
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using javascript is always a little risky, you can never really be sure how (and if) the client's browser will run it, and its hard to tell when that is your problem. Validating these fields on the server side might be a bit safer. That said, I can't understand the js you have written well enough to be able to see if there is a hole in it that would allow invalid values to get through, but there are lots of js tricks in the world that I don't know. If you are determined to do this in js, you may want to write something to logger out the agent that was used when the username is null. You might be able to see if there is a patter of certain browsers or certain versionis that cause this problem, and then you can try to test with that browser.
 
Jalal Jafari
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems you're right buddy. JavaScript is so god damned unreliable. I'm gonna validate my inputs in the Struts actions too.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic