RE: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue

2004-11-10 Thread Parke Jeff
Thanks for your help David.  This is very informative and confirms many
of my suspicions.  

My perspective on the issue is this.  I can understand the technical
constraints on including a Struts action in a JSP given the design
(though, oddly this seems to work fairly well if you do it only once per
JSP).  On the technical side, I've resigned to using absolute URLs with
c:import to prevent response building conflicts when including
multiple Struts actions on one JSP.  But when we're talking about good,
decoupled architecture, does it not make sense to keep various functions
independent of one another by giving them their own Struts action and
their own JSP?  If an action is responsible _only_ for knowing what data
to retrieve from the model and _always_ passing that data on to its own
view aren't we decoupling better (for ease of reuse and simplicity of
architecture) than we could with inheritance and chaining?  

Is there any reason why Struts could not support this in some future
release?

- Jeff

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

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

RE: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue

2004-11-08 Thread Parke Jeff
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-userm=109942705229329w=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-userm=108152145227595w=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

RE: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue

2004-11-08 Thread David G. Friedman
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-userm=109942705229329w=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-userm=108152145227595w=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

Re: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue

2004-11-05 Thread Jeff Beal
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]


Re: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue

2004-11-05 Thread Parke Jeff

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]



Re: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue

2004-11-05 Thread Kris Schneider
Can't really comment on Tiles since I don't use it, but this recent thread may
be of interest:

http://marc.theaimsgroup.com/?t=10976831933

Quoting Parke Jeff [EMAIL PROTECTED]:

 
 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

-- 
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

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



Re: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue

2004-11-05 Thread Thompson Marzagão
I use tiles for it. A typical set of related definitions in my tiles 
configuration file:

   definition name=page.site.home path=/WEB-INF/jsp/layout/main.jsp
   put name=menu value=action.site.menu /
   put name=calendar value=action.site.calendar /
   put name=survey value=action.site.survey /
   put name=greeting value=tile.site.greeting /
   put name=main value=tile.site.home /
   /definition
   definition name=action.site.menu path=/menu.do/
   definition name=action.site.calendar path=/calendar.do/
   definition name=action.site.survey path=/survey.do/
   definition name=tile.site.greeting 
path=/WEB-INF/jsp/tile/site/greeting.jsp/
   definition name=tile.site.home 
path=/WEB-INF/jsp/tile/site/home.jsp/

In the main.jsp file I use tiles:insert for menu, calendar, 
survey, greeting and main

Thompson
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
-Original Message-
From: Parke Jeff 
Sent: Tuesday, November 02, 2004 3:23 PM
To: [EMAIL PROTECTED]
Subject: [] Including a Struts action in a JSP -
IllegalStateException / truncated response issue

Hello,

I've seen a few posts on this subject, through this and other resources,
but I haven't seen any appealing workarounds.  I'd like to try to bring
all the relevant information from these posts together and then ask for
help in identifying a viable workaround.  I apologize in advance if this
issue is well known and understood and I just missed the best resources
on the subject.

Goals:
1)   To build a Struts application where _every_ request to the
application goes through a Struts action that collects and packages data
then forwards (using Struts ActionForward's) to a JSP.
2)   To be able to include one or more Struts actions in any given
JSP (ie: c:import url=/someAction.do /).

Behavior when implementing these goals:
1)   Usually, when executing a single include of a Struts action on
a JSP, everything works fine though sometimes there are problems (as
listed below).
2)   When including more than one Struts action on a JSP I get an
IllegalStateException - Response has already been committed.
3)   Sometimes, when a JSP only includes one Struts action, the
first x bytes of the response will be missing when it is returned
(without exception) to the client.

Relevant issues (correct me where I'm wrong):
1)   Including (jsp:include, c:import, etc.) a JSP/Servlet on a
JSP sometimes (always?) causes the response to be committed because
includes use RequestDispatcher.include() which in turn commits the
response.
2)   Forwarding a request using an ActionForward from a Struts
action to a JSP can not be done when a response has been committed.
3)   Increasing the response buffer size has no effect on these
issues.
4)   Using the include directive (%@ include file=filename %)
won't work because that includes source a translation time.
5)   It has been reported that using tiles:insert does not
(fully/always?) resolve the problematic behavior.
6)   Using absolute URLs with c:import prevents the response from
being committed because the context of the request is assumed to be
independent.  The visibility of an authenticated, populated session can
be affected by passing the jsessionid in on the URL.  This seems to be
the only viable workaround though I haven't tested it thoroughly yet.

Reference:
http://www.mail-archive.com/[EMAIL PROTECTED]/msg13284.html
http://www.jguru.com/faq/view.jsp?EID=501393
http://www.mail-archive.com/[EMAIL PROTECTED]/msg05711.htm
l
http://www.mail-archive.com/[EMAIL PROTECTED]/msg15194.html
http://forum.java.sun.com/thread.jsp?thread=484731forum=45message=2266
277
http://www.mail-archive.com/[EMAIL PROTECTED]/msg15189.html
http://jguru.com/forums/view.jsp?EID=1204797
http://forum.java.sun.com/thread.jsp?thread=461644forum=45message=2115
900
http://www.mail-archive.com/[EMAIL PROTECTED]/msg18018.html
http://www.mail-archive.com/[EMAIL PROTECTED]/msg74816.html
http://www.mail-archive.com/[EMAIL PROTECTED]/msg29073.html

My setup:
-  Oracle AS 10g (OC4J) app server
-  Struts 1.1
-  JSTL 1.0.6

Is there any clean way to meet the two goals listed above without error?

Thanks,
Jeff









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

RE: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue

2004-11-05 Thread David G. Friedman
Jeff,

Try this previous post on IllegalStateException response has already been
committed:
http://marc.theaimsgroup.com/?l=struts-userm=108152145227595w=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]


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



RE: [****] Including a Struts action in a JSP - IllegalStateException / truncated response issue

2004-11-04 Thread Parke Jeff
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

-Original Message-
From: Parke Jeff 
Sent: Tuesday, November 02, 2004 3:23 PM
To: [EMAIL PROTECTED]
Subject: [] Including a Struts action in a JSP -
IllegalStateException / truncated response issue

Hello,

 

I've seen a few posts on this subject, through this and other resources,
but I haven't seen any appealing workarounds.  I'd like to try to bring
all the relevant information from these posts together and then ask for
help in identifying a viable workaround.  I apologize in advance if this
issue is well known and understood and I just missed the best resources
on the subject.

 

Goals:

1)   To build a Struts application where _every_ request to the
application goes through a Struts action that collects and packages data
then forwards (using Struts ActionForward's) to a JSP.

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

 

Behavior when implementing these goals:

1)   Usually, when executing a single include of a Struts action on
a JSP, everything works fine though sometimes there are problems (as
listed below).

2)   When including more than one Struts action on a JSP I get an
IllegalStateException - Response has already been committed.

3)   Sometimes, when a JSP only includes one Struts action, the
first x bytes of the response will be missing when it is returned
(without exception) to the client.

 

Relevant issues (correct me where I'm wrong):

1)   Including (jsp:include, c:import, etc.) a JSP/Servlet on a
JSP sometimes (always?) causes the response to be committed because
includes use RequestDispatcher.include() which in turn commits the
response.

2)   Forwarding a request using an ActionForward from a Struts
action to a JSP can not be done when a response has been committed.

3)   Increasing the response buffer size has no effect on these
issues.

4)   Using the include directive (%@ include file=filename %)
won't work because that includes source a translation time.

5)   It has been reported that using tiles:insert does not
(fully/always?) resolve the problematic behavior.

6)   Using absolute URLs with c:import prevents the response from
being committed because the context of the request is assumed to be
independent.  The visibility of an authenticated, populated session can
be affected by passing the jsessionid in on the URL.  This seems to be
the only viable workaround though I haven't tested it thoroughly yet.

 

Reference:

http://www.mail-archive.com/[EMAIL PROTECTED]/msg13284.html

http://www.jguru.com/faq/view.jsp?EID=501393

http://www.mail-archive.com/[EMAIL PROTECTED]/msg05711.htm
l

http://www.mail-archive.com/[EMAIL PROTECTED]/msg15194.html

http://forum.java.sun.com/thread.jsp?thread=484731forum=45message=2266
277

http://www.mail-archive.com/[EMAIL PROTECTED]/msg15189.html

http://jguru.com/forums/view.jsp?EID=1204797

http://forum.java.sun.com/thread.jsp?thread=461644forum=45message=2115
900

http://www.mail-archive.com/[EMAIL PROTECTED]/msg18018.html

http://www.mail-archive.com/[EMAIL PROTECTED]/msg74816.html

http://www.mail-archive.com/[EMAIL PROTECTED]/msg29073.html

 

My setup:

-  Oracle AS 10g (OC4J) app server

-  Struts 1.1

-  JSTL 1.0.6

 

Is there any clean way to meet the two goals listed above without error?

 

Thanks,

Jeff

 

 

 














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