Your action can implement ServletRequestAware interface to get access to the request object. But I'm afraid the request object will be injected after your constructor runs. Why do you need the request object in the constructor?? Struts 2 actions are not reused, so whatever you want to do in the constructor you can also do in your execute (or whatever named) method...
If you want to do some initialization, I think the best way is to implement Preparable interface so that the prepare interceptor will call the prepare method of your action class. The prepare interceptor is below the servlet config interceptor in the default stack so if your action implements both Preparable interface and ServletRequestAware interface, the HttpServletRequest object would be injected into your action before the prepare method is called...
Joined: Jul 23, 2009
Now there's one neat suggestion. haha im so stupid i never thought of that (my mind is pretty beaten already.. thanks)
Thanks a lot.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: How to access the request object in struts2 action