Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is Action class thread safe

 
Prakash Kumar M
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Recently i had an interview, where i faced a question as


In Action,ActionForm,ActionServlet,ActionMapping classes which are thread safe and why


Can you please let me know the correct answers. I was confused.

Thanks in advance
 
Salil Vverma
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Action is not thread safe as only one instance of an action object is created and all the requests access it.

ActionForm itself is not thread safe reason being when it is stored as an attribute in session, multiple requests can manipulate its values.

ActionServlet is a servlet which is not thread safe.

ActionMapping object should be thread safe, reason being it is initialized only at the time of struts-configuration initialization (at the load time of ActionServlet). After that the configuration is frozen.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic