Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jalal Jafari
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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?
 
Joe Ess
Bartender
Posts: 9319
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are no getters or setters in LoginAction?
 
Jalal Jafari
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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.

 
Tom Rispoli
Ranch Hand
Posts: 349
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic