You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeremy Prellwitz <je...@prellwitz.com> on 2002/06/14 18:37:06 UTC

Re: Starter Action? Where to find Plugin Documentation?

Can someone give me a hint where to find documentation on 
this topic? (i.e. Plugins, how they are configured, and how 
you attach them to events.)

Thanks.


---- Original message ----
>Date: Fri, 14 Jun 2002 08:57:50 -0700 (PDT)
>From: "Craig R. McClanahan" <cr...@apache.org>  
>Subject: Re: Starter Action?  
>To: Struts Users Mailing List <struts-
user@jakarta.apache.org>
>
>
>
>On Thu, 13 Jun 2002, Struts Newsgroup wrote:
>
>> Date: Thu, 13 Jun 2002 23:10:02 -0700
>> From: Struts Newsgroup <st...@basebeans.com>
>> Reply-To: Struts Users Mailing List <struts-
user@jakarta.apache.org>
>> To: struts-user@jakarta.apache.org
>> Subject: Starter Action?
>>
>> Subject: Starter Action?
>> From: "Christopher Cheng" <ch...@netdimensions.com>
>>  ===
>> Is it possbile to define one of the actions to be executed 
during startup
>> instead of defining a new servlet in web.xml?
>>
>
>In Struts 1.1, you can define and register a PlugIn that is 
notified when
>the Struts controller servlet is started and stopped.  The 
init() method
>can do whatever setup things you need.
>
>In Struts 1.0, you can accomplish the same thing by 
subclassing
>org.apache.struts.action.ActionServlet and overriding the 
init() method --
>something like this:
>
>  public void init() throws ServletException {
>    super.init();
>    ... do my own setup ...
>  }
>
>and using this class as the "action" servlet in web.xml.
>
>Craig
>
>
>--
>To unsubscribe, e-mail:   <mailto:struts-user-
unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:struts-user-
help@jakarta.apache.org>
>


===================================
 Experience is something you don't
 get until just after you need it.
===================================

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Starter Action? Where to find Plugin Documentation?

Posted by Chuck Cavaness <ch...@attbi.com>.
I know it doesn't help you now, but Chapter 9 of my book will cover plugins 
and show how to use them. Chapter 9 is finished and will be published very 
shortly at http://www.theserverside.com/resources/strutsreview.jsp.

Chuck

At 08:37 AM 6/14/2002 -0800, you wrote:
>Can someone give me a hint where to find documentation on
>this topic? (i.e. Plugins, how they are configured, and how
>you attach them to events.)
>
>Thanks.
>
>
>---- Original message ----
> >Date: Fri, 14 Jun 2002 08:57:50 -0700 (PDT)
> >From: "Craig R. McClanahan" <cr...@apache.org>
> >Subject: Re: Starter Action?
> >To: Struts Users Mailing List <struts-
>user@jakarta.apache.org>
> >
> >
> >
> >On Thu, 13 Jun 2002, Struts Newsgroup wrote:
> >
> >> Date: Thu, 13 Jun 2002 23:10:02 -0700
> >> From: Struts Newsgroup <st...@basebeans.com>
> >> Reply-To: Struts Users Mailing List <struts-
>user@jakarta.apache.org>
> >> To: struts-user@jakarta.apache.org
> >> Subject: Starter Action?
> >>
> >> Subject: Starter Action?
> >> From: "Christopher Cheng" <ch...@netdimensions.com>
> >>  ===
> >> Is it possbile to define one of the actions to be executed
>during startup
> >> instead of defining a new servlet in web.xml?
> >>
> >
> >In Struts 1.1, you can define and register a PlugIn that is
>notified when
> >the Struts controller servlet is started and stopped.  The
>init() method
> >can do whatever setup things you need.
> >
> >In Struts 1.0, you can accomplish the same thing by
>subclassing
> >org.apache.struts.action.ActionServlet and overriding the
>init() method --
> >something like this:
> >
> >  public void init() throws ServletException {
> >    super.init();
> >    ... do my own setup ...
> >  }
> >
> >and using this class as the "action" servlet in web.xml.
> >
> >Craig
> >
> >
> >--
> >To unsubscribe, e-mail:   <mailto:struts-user-
>unsubscribe@jakarta.apache.org>
> >For additional commands, e-mail: <mailto:struts-user-
>help@jakarta.apache.org>
> >
>
>
>===================================
>  Experience is something you don't
>  get until just after you need it.
>===================================
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Starter Action? Where to find Plugin Documentation?

Posted by James Holmes <jh...@yahoo.com>.
There doesn't appear to be any official documentation
of this other than the config file DTD and the source
code.

DTD:
http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd

You can use the Struts Console to easily
add/modify/delete elements from the config file.

Struts Console:
http://www.jamesholmes.com/struts/

-james
james@jamesholmes.com


--- Jeremy Prellwitz <je...@prellwitz.com> wrote:
> Can someone give me a hint where to find
> documentation on 
> this topic? (i.e. Plugins, how they are configured,
> and how 
> you attach them to events.)
> 
> Thanks.
> 
> 
> ---- Original message ----
> >Date: Fri, 14 Jun 2002 08:57:50 -0700 (PDT)
> >From: "Craig R. McClanahan" <cr...@apache.org>  
> >Subject: Re: Starter Action?  
> >To: Struts Users Mailing List <struts-
> user@jakarta.apache.org>
> >
> >
> >
> >On Thu, 13 Jun 2002, Struts Newsgroup wrote:
> >
> >> Date: Thu, 13 Jun 2002 23:10:02 -0700
> >> From: Struts Newsgroup <st...@basebeans.com>
> >> Reply-To: Struts Users Mailing List <struts-
> user@jakarta.apache.org>
> >> To: struts-user@jakarta.apache.org
> >> Subject: Starter Action?
> >>
> >> Subject: Starter Action?
> >> From: "Christopher Cheng"
> <ch...@netdimensions.com>
> >>  ===
> >> Is it possbile to define one of the actions to be
> executed 
> during startup
> >> instead of defining a new servlet in web.xml?
> >>
> >
> >In Struts 1.1, you can define and register a PlugIn
> that is 
> notified when
> >the Struts controller servlet is started and
> stopped.  The 
> init() method
> >can do whatever setup things you need.
> >
> >In Struts 1.0, you can accomplish the same thing by
> 
> subclassing
> >org.apache.struts.action.ActionServlet and
> overriding the 
> init() method --
> >something like this:
> >
> >  public void init() throws ServletException {
> >    super.init();
> >    ... do my own setup ...
> >  }
> >
> >and using this class as the "action" servlet in
> web.xml.
> >
> >Craig
> >
> >
> >--
> >To unsubscribe, e-mail:   <mailto:struts-user-
> unsubscribe@jakarta.apache.org>
> >For additional commands, e-mail:
> <mailto:struts-user-
> help@jakarta.apache.org>
> >
> 
> 
> ===================================
>  Experience is something you don't
>  get until just after you need it.
> ===================================
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Starter Action? Where to find Plugin Documentation?

Posted by James Mitchell <jm...@telocity.com>.
It's been mentioned before about using a forward as your index.jsp
That would almost guarantee that an initial action was executed.  The
exception being if someone uses a bookmark.  Although, there are several
work-arounds for that as well. (redirect/forward to index.jsp on session
expire)

This has mostly been mentioned in the context of having all jsp under the
WEB-INF and related topics.  The idea being: "No Request will be served
except through an Action".

I've also see quite a few "our company won't let us do this" msg, so if you
have the flexibility to use forward as your index.jsp, go for it!

I have a version of the struts-example that does this.  Also Ted Husted's
artimus app does this as well (although much cleaner than
mine)....hmm....maybe I'll change it;)

Hope that helps!!!

James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the "Open Minded Developer Network"
http://struts-atlanta.open-tools.org

> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: Friday, June 14, 2002 2:28 PM
> To: Struts Users Mailing List; jeremy@prellwitz.com
> Subject: Re: Starter Action? Where to find Plugin Documentation?
>
>
>
>
> On Fri, 14 Jun 2002, Jeremy Prellwitz wrote:
>
> > Date: Fri, 14 Jun 2002 08:37:06 -0800
> > From: Jeremy Prellwitz <je...@prellwitz.com>
> > Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>,
> >      jeremy@prellwitz.com
> > To: Struts Users Mailing List <st...@jakarta.apache.org>
> > Subject: Re: Starter Action?  Where to find Plugin Documentation?
> >
> > Can someone give me a hint where to find documentation on
> > this topic? (i.e. Plugins, how they are configured, and how
> > you attach them to events.)
> >
>
> Right now it's just documented in the javadocs and the DTD -- but it's
> really simple.  When the controller servlet is first stated, it will
> instantiate all the plugins you have defined and call the init() method of
> each one.  Likewise, when the controller shuts down, it will call the
> destroy() method of each previously instantiated plugin.  Essentially,
> your plugin has exactly the same lifecycle characteristics as the
> controller servlet itself.
>
> The struts-config.xml file for the struts-example application in 1.1 has a
> plugin for the "user database" object.  You can take a look at this to see
> how plugins are configured.
>
> One detail I glossed over, though -- you cannot actually call an Action in
> your plugin's initialization, because that requires having a request and
> response available.  However, you can do whatever initialization that you
> would have done in that action, by pulling that logic out into separate
> classes.
>
> > Thanks.
> >
>
> Craig
>
>
> >
> > ---- Original message ----
> > >Date: Fri, 14 Jun 2002 08:57:50 -0700 (PDT)
> > >From: "Craig R. McClanahan" <cr...@apache.org>
> > >Subject: Re: Starter Action?
> > >To: Struts Users Mailing List <struts-
> > user@jakarta.apache.org>
> > >
> > >
> > >
> > >On Thu, 13 Jun 2002, Struts Newsgroup wrote:
> > >
> > >> Date: Thu, 13 Jun 2002 23:10:02 -0700
> > >> From: Struts Newsgroup <st...@basebeans.com>
> > >> Reply-To: Struts Users Mailing List <struts-
> > user@jakarta.apache.org>
> > >> To: struts-user@jakarta.apache.org
> > >> Subject: Starter Action?
> > >>
> > >> Subject: Starter Action?
> > >> From: "Christopher Cheng" <ch...@netdimensions.com>
> > >>  ===
> > >> Is it possbile to define one of the actions to be executed
> > during startup
> > >> instead of defining a new servlet in web.xml?
> > >>
> > >
> > >In Struts 1.1, you can define and register a PlugIn that is
> > notified when
> > >the Struts controller servlet is started and stopped.  The
> > init() method
> > >can do whatever setup things you need.
> > >
> > >In Struts 1.0, you can accomplish the same thing by
> > subclassing
> > >org.apache.struts.action.ActionServlet and overriding the
> > init() method --
> > >something like this:
> > >
> > >  public void init() throws ServletException {
> > >    super.init();
> > >    ... do my own setup ...
> > >  }
> > >
> > >and using this class as the "action" servlet in web.xml.
> > >
> > >Craig
> > >
> > >
> > >--
> > >To unsubscribe, e-mail:   <mailto:struts-user-
> > unsubscribe@jakarta.apache.org>
> > >For additional commands, e-mail: <mailto:struts-user-
> > help@jakarta.apache.org>
> > >
> >
> >
> > ===================================
> >  Experience is something you don't
> >  get until just after you need it.
> > ===================================
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Starter Action? Where to find Plugin Documentation?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 14 Jun 2002, Jeremy Prellwitz wrote:

> Date: Fri, 14 Jun 2002 08:37:06 -0800
> From: Jeremy Prellwitz <je...@prellwitz.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>,
>      jeremy@prellwitz.com
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: Starter Action?  Where to find Plugin Documentation?
>
> Can someone give me a hint where to find documentation on
> this topic? (i.e. Plugins, how they are configured, and how
> you attach them to events.)
>

Right now it's just documented in the javadocs and the DTD -- but it's
really simple.  When the controller servlet is first stated, it will
instantiate all the plugins you have defined and call the init() method of
each one.  Likewise, when the controller shuts down, it will call the
destroy() method of each previously instantiated plugin.  Essentially,
your plugin has exactly the same lifecycle characteristics as the
controller servlet itself.

The struts-config.xml file for the struts-example application in 1.1 has a
plugin for the "user database" object.  You can take a look at this to see
how plugins are configured.

One detail I glossed over, though -- you cannot actually call an Action in
your plugin's initialization, because that requires having a request and
response available.  However, you can do whatever initialization that you
would have done in that action, by pulling that logic out into separate
classes.

> Thanks.
>

Craig


>
> ---- Original message ----
> >Date: Fri, 14 Jun 2002 08:57:50 -0700 (PDT)
> >From: "Craig R. McClanahan" <cr...@apache.org>
> >Subject: Re: Starter Action?
> >To: Struts Users Mailing List <struts-
> user@jakarta.apache.org>
> >
> >
> >
> >On Thu, 13 Jun 2002, Struts Newsgroup wrote:
> >
> >> Date: Thu, 13 Jun 2002 23:10:02 -0700
> >> From: Struts Newsgroup <st...@basebeans.com>
> >> Reply-To: Struts Users Mailing List <struts-
> user@jakarta.apache.org>
> >> To: struts-user@jakarta.apache.org
> >> Subject: Starter Action?
> >>
> >> Subject: Starter Action?
> >> From: "Christopher Cheng" <ch...@netdimensions.com>
> >>  ===
> >> Is it possbile to define one of the actions to be executed
> during startup
> >> instead of defining a new servlet in web.xml?
> >>
> >
> >In Struts 1.1, you can define and register a PlugIn that is
> notified when
> >the Struts controller servlet is started and stopped.  The
> init() method
> >can do whatever setup things you need.
> >
> >In Struts 1.0, you can accomplish the same thing by
> subclassing
> >org.apache.struts.action.ActionServlet and overriding the
> init() method --
> >something like this:
> >
> >  public void init() throws ServletException {
> >    super.init();
> >    ... do my own setup ...
> >  }
> >
> >and using this class as the "action" servlet in web.xml.
> >
> >Craig
> >
> >
> >--
> >To unsubscribe, e-mail:   <mailto:struts-user-
> unsubscribe@jakarta.apache.org>
> >For additional commands, e-mail: <mailto:struts-user-
> help@jakarta.apache.org>
> >
>
>
> ===================================
>  Experience is something you don't
>  get until just after you need it.
> ===================================
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>