Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About Action objects in Struts

 
Val Pecaoco
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
I have some basic questions about Action objects:
1) Are Action objects servlets or Java beans?
2) If they are servlets, how can you pass initialization params to them? I tried the usual code in the init() method of a servlet, but it does not work.
Thanks in advance for the help.
Ex Animo Java!
-- Val

--------------------------------------------
"In your anger, don't sin." (Ephesians 4:26)
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Are Action objects servlets or Java beans?
Neither. To quote the API, "An Action is an adapter between the contents of an incoming HTTP request and the corresponding business logic that should be executed to process this request".
Remember, a JavaBean is basically just a regular Java object that has the null constructor and getXxx and setXxx methods for its attributes. The Action class does not fit this criteria. Neither is it a Servlet
2) If they are servlets, how can you pass initialization params to them? I tried the usual code in the init() method of a servlet, but it does not work.
Your controller servlet in Struts is an instance of ActionServlet. This is usually implicitly generated based on the contents of the struts-config.xml file.
 
Val Pecaoco
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,
Thanks!
I guess I'm grossly mistaken, because I thought that if it's involved in a Web application it must either be a servlet, JSP, or JavaBean.
Does that mean that an "adapter" is a Java class that isn't a servlet, JSP, or JavaBean?
Ex Animo Java!
-- Val
[ July 03, 2002: Message edited by: Val Pecaoco ]
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check the JavaRanch newsletter archive for the article on Struts written by one of our resident dopey sheriffs?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic