aspose file tools*
The moose likes Struts and the fly likes Struts 2: HttpServletRequest is null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2: HttpServletRequest is null" Watch "Struts 2: HttpServletRequest is null" New topic
Author

Struts 2: HttpServletRequest is null

Rusty Enisin
Ranch Hand

Joined: May 26, 2005
Posts: 107
Hi all. I have a Login action that gets intercepted by non other than LoginInterceptor. In the interceptor the username and password are checked. I can even print them in the logs to see that they are really there.

The interceptor returns
[code]
return invocation.invoke();
[\code]

Then in the Login action username, password and HttpServletRequest are all null. I have setters for each. I am implementing ServletRequestAware.

Worst of all this was all working yesterday. This happened once before but then started working. Which all means I have no clue what I did or how to fix this.


The squeaky wheel gets the grease. Well, that or replaced...
Rusty Enisin
Ranch Hand

Joined: May 26, 2005
Posts: 107
Ok. I got the answer. I will post it here in case someone else comes along.

I had my interceptors set up like this. The loginInterceptor is one that I wrote. But, being custom it bypasses Struts 2's way of populating the request and properties. Trade out this code for the following:

Old:


Fix:
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts 2: HttpServletRequest is null
 
Similar Threads
Bean values are null
Struts 2 addActionError problem
struts2 login interceptor not finding session attribute of user details.
Struts 2 Question
Logout is not properly working in struts2 please help me