Jeff,

I have an odd idea why you are having your problem.  In the first request
included below you wrote:

> I'm still having trouble including a Struts action
> into a JSP (<c:import url="/someAction.do" />).

Trying to import a struts action is likely the cause of your problem.  Any
action called after another action forces the whole ActionServlet processing
to begin again.  So you are parsing the request in your original action and
going to a JSP, that JSP sets any final headers and sends them to the client
and WHAM you force Struts to try to do that AGAIN on an output stream that
has already begin being sent to the client.  Your import of an action tries
to perform the whole process again, including setting headers (BOOM!) and
your code goes haywire at this point.  Chaining actions inside the Server
(unless you send redirects to the client) isn't an efficient way to do
multiple setups.  There have been plenty of discussion threads about having
an action invoking another action as it's "success" ActionForward mapping
and how that reprocesses the input again and can reset any data in the bean
(if both Actions use the same bean) back to the submitted ones EVEN IF they
were changed whiel being processed by the first Action.

One key spec you noted in your original request:

> 2)       To be able to include one or more
> Struts actions in any given JSP (ie:
> <c:import url="/someAction.do" />).

A better way, than chaining actions or trying to import output from another
(BOOM!) action, would be to have either a base Action subclass of your own
or common code that all actions invoke which would:

A. Decide what beans to populate and the names used to save them in scope
(probably request scope).

B. Decide what JSP's to include in your tile and in what order so it can
display the data saved in step "A" above.  Tiles has a "putList" feature
which can cause JSP's to be inserted into a section of a tile template.  See
the Tiles Advanced Features PDF I mentioned in a previous email, chapter
6.4.2. That section is simply an example of putList with JSPs.

If you do not like the idea of making a base Action class of your own to
subclass for all of your Actions, you could move the A/B steps coding into a
subclass of RequestProcessor (or TilesRequestProcessor) so the processing
occurs for all Actions and you can then use standard Action classes for your
site.

Or, you could go wild & crazy and try Struts Chains to see if that fits.

Regards,
David

-----Original Message-----
From: Parke Jeff [mailto:[EMAIL PROTECTED]
Sent: Monday, November 08, 2004 9:41 AM
To: David G. Friedman; Struts Users Mailing List
Subject: RE: [****] Including a Struts action in a JSP -
IllegalStateException / truncated response issue

Thanks for the information guys.

I actually have tried upping the response buffer size in a variety of
places (JSP, Struts action, application server configuration) but it
didn't fix the problem for me.

As for ensuring that the headers aren't messed with in the included
resource (JSP/Struts action), I don't know that this is easy to do.  I
can tell you that I do not believe I am doing any operation that would
cause a change to the response headers.  However, I have read that
simply performing an include can cause a response to be committed and
subsequently performing a forward (using ActionForward) can cause an
IllegalStateException.  I don't really understand this, both
conceptually and based on experiment but it seems to be inconsistently
true nonetheless.  It seems that the first include of a Struts action
goes through fine (usually, sometimes truncated buffer), but the second
or third include of a Struts action (for me) causes an
IllegalStateException.

Anyway, I've been able to skirt the issue by using absolute URLs in my
<c:include> statement, a trick which seems to bypass the include
operation's commit of the response.  This is far from ideal as the
request scope is different between the included resource and the calling
one, so I'm still very interested in help finding out whether my issues
are common, whether they should be considered symptoms of a bug, and
whether there is a cleaner workaround that the one described above.

Have a look at my original post, which got lost in the thread, for more
background and related resources:

http://marc.theaimsgroup.com/?l=struts-user&m=109942705229329&w=2

Thanks again,
Jeff

-----Original Message-----
From: David G. Friedman [mailto:[EMAIL PROTECTED]
Sent: Friday, November 05, 2004 6:18 PM
To: Struts Users Mailing List
Subject: RE: [****] Including a Struts action in a JSP -
IllegalStateException / truncated response issue

Jeff,

Try this previous post on IllegalStateException response has already
been
committed:
http://marc.theaimsgroup.com/?l=struts-user&m=108152145227595&w=2

The author suggested 2 courses of action:

1. Try increasing the buffer size on myjsp.jsp. Default is 8kb
2. Make sure that you are not changing the header portion of the
response in your included JSP page.

I remember a post with the same exception and the issue was a buffer
issue.

Regards,
David

-----Original Message-----
From: Parke Jeff [mailto:[EMAIL PROTECTED]
Sent: Friday, November 05, 2004 11:28 AM
To: [EMAIL PROTECTED]
Cc: Struts Users Mailing List
Subject: Re: [****] Including a Struts action in a JSP -
IllegalStateException / truncated response issue

Thanks for the information, Jeff.

Unfortunately, though the Tiles Advanced Features Guide indicates it is
possible to include multiple Struts actions (using <tiles:insert>) on
one page, I _still_ get the IllegalStateException Response has already
been committed.

"We often need to prepare data to be shown by a JSP page. In the MVC
framework, the controller prepares data (in the model) to be shown by
the view. Translated to Tiles and Struts, we can use a Struts Action as
a controller, a JSP page as a view, and combine both in a Tile. So, when
you insert the Tile, the Action is called before the JSP page is
displayed. Now, your complex web page can be made of Tiles fed by
controllers (one sub-controller for each Tile). This approach is better
than one single controller for all Tiles of the page, because it really
allows building autonomous Tiles, without worrying about how to fed
(sic) them all." - Tiles Advanced Features Guide
(http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf)

This is describing exactly what I want to accomplish and the reason for
it but I keep running into the same committed response problem.  Is it
possible that this is a container issue rather than being a Struts
issue?  Can someone else confirm that <c:import> and <tiles:insert> both
cause an IllegalStateException when including more than 1 (actually try
3 or 4) Struts action on the same JSP?

Thanks again for anyone who can help,
Jeff


--------------------------------------------------------
I think that it is unusual to directly include Struts actions in JSP
files. When composing pages of different parts, Tiles is the much more
common approach. The standard usage of Tiles is to include JSP files
directly, but you can use tiles to include Struts actions in JSP files.
(See Section 5.2 of the Tiles Advanced Features guide, a PDF file, at
http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf.)
-- Jeff
--------------------------------------------------------
Parke Jeff wrote:
I'm still having trouble including a Struts action into a JSP (<c:import
url="/someAction.do" />).
I've tried using absolute URLs, passing the jsessionid to ensure that
the session is not lost, but the request context is different between
the JSP and the included action, so this not suitable for many
situations.  I've also tried upgrading to Struts 1.2.4.  This does not
resolve the "Response has already been committed" issue when including
more than one Struts action in a JSP.

The app server is using JRE 1.4.1_03-b02.
Can anyone tell me whether they have seen this situation before?  How
common is it?  Is it unusual to include Struts actions in JSPs?  Anyone?

Thanks,
Jeff




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to