You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Thom Burnett <th...@gmail.com> on 2006/12/05 20:58:59 UTC

The first request

I need to set up my first page with a sequence of database interactions
before the execute() method is called (I think). What's the recommended
struts way of doing so.


When a first request to my jsp page arrives, I need to read some key
parameters of the request, contact my database, and then fill in some fields
of the page based on what the parameters and database tell me. I'm not clear
on how to hook that in. I don't seem to have access to the doPost() and
doGet() methods that I would with a standard servlet.

1. One obvious solution is to extend the struts ActionServlet so that I can
override the doGet() and/or doPost(). Does that interfere with standard
struts behavior?

2. I could also use a standard servlet to handle the request and then
forward or redirect to my struts pages and servlet. That seems to somewhat
defeat the purpose of struts but it could be done.

3. I could also put a lot of java into my jsp page to do all my processing
but that's a violation of MVC and pretty messy as well.

4. I thought about using the constructor of my ActionForm since it gets
called at the right time but I don't have the request object available (and
I need those parameters).

5. Any other ideas?

I need a solution (preferably an example) that works for struts 1.3.5. with
an ActionForm (not the DynaActionForm).

Re: The first request

Posted by Wendy Smoak <ws...@gmail.com>.
On 12/5/06, Thom Burnett <th...@gmail.com> wrote:

> I need to set up my first page with a sequence of database interactions
> before the execute() method is called (I think). What's the recommended
> struts way of doing so.

All requests go through the controller, never straight to the JSP.

Once that pattern is established, you can either have a separate
'setup' action, or use a dispatch-style action with a setup method.

There are several good tutorials here, I believe 'Lesson 2' shows a
setup action.  http://learntechnology.net/

-- 
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: The first request

Posted by "Asthana, Rahul" <Ra...@CIBC.com>.
Actually org.apache.struts.tiles.Controller is called just before the tile is inserted, and that would be after the action forwards to the JSP.That may not satisfy your requirement.

-----Original Message-----
From: Asthana, Rahul [mailto:Rahul.Asthana@CIBC.com]
Sent: Tuesday, December 05, 2006 3:13 PM
To: Struts Users Mailing List
Subject: RE: The first request


Look at  org.apache.struts.tiles.Controller 
I couldnt find a decent example though.
Here is an article.
http://www.theserverside.com/tt/articles/article.tss?l=Tiles101
That of course means that you will have to use Tiles.


-----Original Message-----
From: Thom Burnett [mailto:thom.burnett@gmail.com]
Sent: Tuesday, December 05, 2006 2:59 PM
To: Struts Users Mailing List
Subject: The first request


I need to set up my first page with a sequence of database interactions
before the execute() method is called (I think). What's the recommended
struts way of doing so.


When a first request to my jsp page arrives, I need to read some key
parameters of the request, contact my database, and then fill in some fields
of the page based on what the parameters and database tell me. I'm not clear
on how to hook that in. I don't seem to have access to the doPost() and
doGet() methods that I would with a standard servlet.

1. One obvious solution is to extend the struts ActionServlet so that I can
override the doGet() and/or doPost(). Does that interfere with standard
struts behavior?

2. I could also use a standard servlet to handle the request and then
forward or redirect to my struts pages and servlet. That seems to somewhat
defeat the purpose of struts but it could be done.

3. I could also put a lot of java into my jsp page to do all my processing
but that's a violation of MVC and pretty messy as well.

4. I thought about using the constructor of my ActionForm since it gets
called at the right time but I don't have the request object available (and
I need those parameters).

5. Any other ideas?

I need a solution (preferably an example) that works for struts 1.3.5. with
an ActionForm (not the DynaActionForm).

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: The first request

Posted by "Asthana, Rahul" <Ra...@CIBC.com>.
Look at  org.apache.struts.tiles.Controller 
I couldnt find a decent example though.
Here is an article.
http://www.theserverside.com/tt/articles/article.tss?l=Tiles101
That of course means that you will have to use Tiles.


-----Original Message-----
From: Thom Burnett [mailto:thom.burnett@gmail.com]
Sent: Tuesday, December 05, 2006 2:59 PM
To: Struts Users Mailing List
Subject: The first request


I need to set up my first page with a sequence of database interactions
before the execute() method is called (I think). What's the recommended
struts way of doing so.


When a first request to my jsp page arrives, I need to read some key
parameters of the request, contact my database, and then fill in some fields
of the page based on what the parameters and database tell me. I'm not clear
on how to hook that in. I don't seem to have access to the doPost() and
doGet() methods that I would with a standard servlet.

1. One obvious solution is to extend the struts ActionServlet so that I can
override the doGet() and/or doPost(). Does that interfere with standard
struts behavior?

2. I could also use a standard servlet to handle the request and then
forward or redirect to my struts pages and servlet. That seems to somewhat
defeat the purpose of struts but it could be done.

3. I could also put a lot of java into my jsp page to do all my processing
but that's a violation of MVC and pretty messy as well.

4. I thought about using the constructor of my ActionForm since it gets
called at the right time but I don't have the request object available (and
I need those parameters).

5. Any other ideas?

I need a solution (preferably an example) that works for struts 1.3.5. with
an ActionForm (not the DynaActionForm).

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org