I have a JSP form which has fields for "product name", "price", etc. When clicking submit button of this page it invokes ProductAction class which looks like
Question --- Is it proper to define "productName" as class variable ? What if multiple users access this JSP page , then each of their request will come to TestAction, will this "productName" be safe in the sense it does not mess up the input from different users ?
Struts 1 Actions are singletons and must be thread-safe since there will only be one instance of a class to handle all requests for that Action. The singleton strategy places restrictions on what can be done with Struts 1 Actions and requires extra care to develop. Action resources must be thread-safe or synchronized.
and that of Struts2:
Struts 2 Action objects are instantiated for each request, so there are no thread-safety issues. (In practice, servlet containers generate many throw-away objects per request, and one more object does not impose a performance penalty or impact garbage collection.)
Like it's been pointed out, Struts 2 actions are NOT singletons, they're instantiated for every user request. So you don't have to worry about thread-safety, your instance(and of course class) variables are inherently thread-safe.
Coderanch, best ever forum on the net. Hands down.
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