File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts2 parameters is coming null in action class when using Interceptors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 parameters is coming null in action class when using Interceptors" Watch "Struts2 parameters is coming null in action class when using Interceptors" New topic
Author

Struts2 parameters is coming null in action class when using Interceptors

Santhosh Kalisamy
Ranch Hand

Joined: Apr 15, 2008
Posts: 56
Hi,

When I am using Interceptors, the values on Action class coming as null. I have removed the Interceptors, the values coming perfect from the JSP page.

Login.jsp



LoginAction.java

web.xml


struts.xml (working version)



struts.xml (Notworking version )


AuthenticationInterceptor.java


Logs statements (both cases)



Any suggestions?
Santhosh Kalisamy
Ranch Hand

Joined: Apr 15, 2008
Posts: 56
Fixed this issue by including default Interceptors.



struts.xml


Hope this helps, you all.
Alessandro Gentile
Greenhorn

Joined: Jul 27, 2010
Posts: 12

With Struts 2.3.15 still the same issue.
Your workaround works fine. Thanks Santhosh!!!


OCMJEA/SCEA 5
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

Alessandro Gentile wrote:With Struts 2.3.15 still the same issue.


This is not an "issue". This is how Struts works. The ParametersInterceptor places the request parameters on the Value Stack and the ActionMappingParametersInterceptor sets the values on the Action. If you do not have these interceptors in your stack, the values in your action will be null.
It is a good idea to read the Interceptor documentation before changing interceptor stack or you can have other side effects as well.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Alessandro Gentile
Greenhorn

Joined: Jul 27, 2010
Posts: 12

Hi Joe, I've just made a fool of myself!!
I was misled by the previous post where this whole matter is presented as an "issue".
I confess my utter ignorance. Struts2 has a steep learning curve, there's a lot to read!
Thanks for your advice!!!
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8843
    
    7

No worries. Once you get the hang of it, it is pretty slick how you can drop in Interceptors to modify how Struts works, but yea, just starting out it's pretty strange.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts2 parameters is coming null in action class when using Interceptors
 
Similar Threads
http 404 error in uploading the file
Struts2 parameters is coming null in action class
Issue configuring global results
Http Server 404
Interceptor messes up action class in Struts2