aspose file tools*
The moose likes Struts and the fly likes Recieving 'null' values from a jsp page in Struts2 Action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Recieving Watch "Recieving New topic
Author

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

Jalal Jafari
Greenhorn

Joined: Jul 13, 2009
Posts: 3
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

Joined: Oct 29, 2001
Posts: 8997
    
    9

There are no getters or setters in LoginAction?


[How To Ask Questions On JavaRanch]
Jalal Jafari
Greenhorn

Joined: Jul 13, 2009
Posts: 3
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

Joined: Aug 29, 2008
Posts: 349
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

Joined: Jul 13, 2009
Posts: 3
Seems you're right buddy. JavaScript is so god damned unreliable. I'm gonna validate my inputs in the Struts actions too.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Recieving 'null' values from a jsp page in Struts2 Action