Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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.
 
wood burning stoves
 
subject: Struts2 - Using ServletRequestAware is ok if we have multiple methods in action class?
 
Similar Threads
Struts2 newB: some simple questions
Probably Easy Struts2 Question - SessionAware
migration to Struts2
Working with Struts2
Struts2 and setting data before a form is displayed.