You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Blackburn <cb...@stinkytoe.com> on 2003/11/18 00:13:07 UTC

Including multiple servlets from a jsp page.

I am trying to build a web page that will have multiple dynamic content
fed from multiple servlets. I thought I could just do something like:

<-- index.jsp -->

<c:import url="top.jsp"/>
<c:import url="/servlet1.do"/>
<c:import url="/servlet2.do"/>
<c:import url="bottom.jsp"/>

<-- end -->
What I would like to happen is have the struts servlet be run, and have
the resulting jsp page (defined in the <forward> section of my
struts-config.xml) be "imported" into that spot. This works just fine if
there is only one servlet being called, but fails if there are more. The
error is "Cannot forward after result has been committed".

What do I need to do? Do I need to look at something like tiles? Any help,
or references to some help would be great.

Thanks,

Chris

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


Re: Including multiple servlets from a jsp page.[Now: Tiles Help]

Posted by Chris Blackburn <cb...@stinkytoe.com>.
Thank you very much! That was exactly what I needed. Now I just need a 
little advice on working with Tiles.
Do I need to have a tiles definition for every single different view?

 I will give a small example.

<definition name="page.default" path="/templates/index.jsp">
  <put name="head" value="/common/head.jsp" />
  <put name="centersection" value="center.section" />
  <put name="bottomtable" value="/common/bottomtable.jsp" />
 </definition>
<definition name="center.section" path="/templates/centersection.jsp">
  <put name="leftbar" value="left.bar" />
  <put name="mainsection" value="/common/mainsection.jsp" />
 </definition>
<definition name="left.bar" path="/templates/leftbar.jsp">
  <put name="first" value="/common/navigation.jsp" />
  <put name="second" value="list.events" />
 </definition>

This will give me the look for my front page. But lets say once you log 
in, you have a different 'left.bar'. So I would have to add:

<definition name="login.page.default" extends="stinkytoe.default">
  <put name="centersection" value="login.center.section" />
 </definition>
<definition name="login.center.section" extends="center.section">
  <put name="leftbar" value="login.left.bar" />
 </definition>
<definition name="login.left.bar" extends="left.bar">
  <put name="second" value="/common/userinfo.jsp" />
 </definition>

That seems like a ton of work for each new view. If my 'mainsection' is 
my content area, that means I need to add 2 definitions for each new 
content page? Is there a way to dynamically insert a page as the 
'mainsection' Am I missing something here?

Thanks again,

Chris


Hubert Rabago wrote:

>Tiles is one way to do it.  Take a look at the Tiles Controller.
>http://jakarta.apache.org/struts/api/org/apache/struts/tiles/Controller.html
>
>Check out http://www.theserverside.com/resources/article.jsp?l=Tiles101 for some
>explanation on it.
>
>--- Chris Blackburn <cb...@stinkytoe.com> wrote:
>  
>
>>I am trying to build a web page that will have multiple dynamic content
>>fed from multiple servlets. I thought I could just do something like:
>>
>><-- index.jsp -->
>>
>><c:import url="top.jsp"/>
>><c:import url="/servlet1.do"/>
>><c:import url="/servlet2.do"/>
>><c:import url="bottom.jsp"/>
>>
>><-- end -->
>>What I would like to happen is have the struts servlet be run, and have
>>the resulting jsp page (defined in the <forward> section of my
>>struts-config.xml) be "imported" into that spot. This works just fine if
>>there is only one servlet being called, but fails if there are more. The
>>error is "Cannot forward after result has been committed".
>>
>>What do I need to do? Do I need to look at something like tiles? Any help,
>>or references to some help would be great.
>>
>>Thanks,
>>
>>Chris
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>    
>>
>
>
>__________________________________
>Do you Yahoo!?
>Protect your identity with Yahoo! Mail AddressGuard
>http://antispam.yahoo.com/whatsnewfree
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>  
>



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


Re: Including multiple servlets from a jsp page.

Posted by Hubert Rabago <ja...@yahoo.com>.
Tiles is one way to do it.  Take a look at the Tiles Controller.
http://jakarta.apache.org/struts/api/org/apache/struts/tiles/Controller.html

Check out http://www.theserverside.com/resources/article.jsp?l=Tiles101 for some
explanation on it.

--- Chris Blackburn <cb...@stinkytoe.com> wrote:
> I am trying to build a web page that will have multiple dynamic content
> fed from multiple servlets. I thought I could just do something like:
> 
> <-- index.jsp -->
> 
> <c:import url="top.jsp"/>
> <c:import url="/servlet1.do"/>
> <c:import url="/servlet2.do"/>
> <c:import url="bottom.jsp"/>
> 
> <-- end -->
> What I would like to happen is have the struts servlet be run, and have
> the resulting jsp page (defined in the <forward> section of my
> struts-config.xml) be "imported" into that spot. This works just fine if
> there is only one servlet being called, but fails if there are more. The
> error is "Cannot forward after result has been committed".
> 
> What do I need to do? Do I need to look at something like tiles? Any help,
> or references to some help would be great.
> 
> Thanks,
> 
> Chris
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree

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