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 - Using ServletRequestAware is ok if we have multiple methods in action class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts2 - Using ServletRequestAware is ok if we have multiple methods in action class?" Watch "Struts2 - Using ServletRequestAware is ok if we have multiple methods in action class?" New topic
Author

Struts2 - Using ServletRequestAware is ok if we have multiple methods in action class?

anand kumarblr
Greenhorn

Joined: Oct 27, 2006
Posts: 27
Iam using struts2 Action.In single action class iam having 4 methods.
I have a separate action mapping names for all 4 methods and it works fine.

Before i was using HttpServletRequest request = ServletActionContext.getRequest();
in all 4 methods to get request object.

Now i changed the action class to implement ServletRequestAware interface.
and added in class..
private HttpServletRequest request;
public void setServletRequest(HttpServletRequest request) {
this.request = request;
}

Now all 4 methods accessing the common request object.

I want know whether it will create concurrency problem when multiple Users try to access different methods at the same time
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Actions are instantiated per-request.
anand kumarblr
Greenhorn

Joined: Oct 27, 2006
Posts: 27
Thanks i think that solves the problem.
 
GeeCON Prague 2014
 
subject: Struts2 - Using ServletRequestAware is ok if we have multiple methods in action class?