You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Erickson <de...@cmcflex.com> on 2003/10/29 23:04:29 UTC

Tiles Redirect Bug on a per Tile basis? Help!

Bug description:
Using tiles to handle our webpage.  I have an individual tile which is a jsp
that does some logic on our forums, if a certain situation occurs that tile
when loaded will attempt to redirect to a error page.  However this does not
work.  Instead where that tile should be it just comes up blank.  I have
also tried getting the request dispatcher and forwarding if that error
occurs but it says that the response has been commited and throws an
exception..  so how in the world am I supposed to insert a different page
there if this condition comes up!

(I'm not using struts actions on this particular area of the webpage yet so
the logic is contained in the jsp)

Help!
-Thanks
David


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


Re: Tiles Redirect Bug on a per Tile basis? Help!

Posted by David Erickson <de...@cmcflex.com>.
Ya I wish I knew why the redirects inside a tile aren't working..
theoretically they should unless there is a specific reason they were coded
not too... but nobody else seems to know either :p
-David

----- Original Message ----- 
From: "Adam Hardy" <ah...@cyberspaceroad.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, October 30, 2003 4:09 PM
Subject: Re: Tiles Redirect Bug on a per Tile basis? Help!


> On 10/30/2003 11:26 PM David Erickson wrote:
> > I was able to make it work using the <jsp:include page"blah"/> tag.  I
found
> > some interesting stuff with it though.  The page url is relative to your
> > context.  So if my context was /salesweb, and i wanted the page at
> > /salesweb/forum/transition-.jsp  I would need to send it
> > /forum/transition-.jsp.  Also when I tried <jsp:include page"<%=
> > request.getContextPath() %>/forum/transition-.jsp"/> I would get a
compile
> > error (this was before I figured out it was context relative), however
> > <jsp:include page"<%=  StringNameHere %>"/> would work.  Very odd.  I
just
> > wish the original redirect would work, so my code doens't look all
sloppy ;)
>
> Nobody else has jumped in on this thread to say anything different, but
> I don't actually claim that the tiles redirect can't work. Originally I
> thought you wanted the whole lot to redirect, not just the tile, which I
> know will work.
>
> I just don't know enough about the internal Tiles machinations.
>
> Adam
>
> -- 
> struts 1.1 + tomcat 5.0.12 + java 1.4.2
> Linux 2.4.20 RH9
>
>
> ---------------------------------------------------------------------
> 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: Tiles Redirect Bug on a per Tile basis? Help!

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
On 10/30/2003 11:26 PM David Erickson wrote:
> I was able to make it work using the <jsp:include page"blah"/> tag.  I found
> some interesting stuff with it though.  The page url is relative to your
> context.  So if my context was /salesweb, and i wanted the page at
> /salesweb/forum/transition-.jsp  I would need to send it
> /forum/transition-.jsp.  Also when I tried <jsp:include page"<%=
> request.getContextPath() %>/forum/transition-.jsp"/> I would get a compile
> error (this was before I figured out it was context relative), however
> <jsp:include page"<%=  StringNameHere %>"/> would work.  Very odd.  I just
> wish the original redirect would work, so my code doens't look all sloppy ;)

Nobody else has jumped in on this thread to say anything different, but 
I don't actually claim that the tiles redirect can't work. Originally I 
thought you wanted the whole lot to redirect, not just the tile, which I 
know will work.

I just don't know enough about the internal Tiles machinations.

Adam

-- 
struts 1.1 + tomcat 5.0.12 + java 1.4.2
Linux 2.4.20 RH9


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


Re: Tiles Redirect Bug on a per Tile basis? Help!

Posted by David Erickson <de...@cmcflex.com>.
Adam,
I agree with you.. I'm not a big fan of logic in jsps other than minimal
stuff, but in this circumstance we are retooling a jsp based forum and
eventually will port it to struts but at the moment time is scarce.

I was able to make it work using the <jsp:include page"blah"/> tag.  I found
some interesting stuff with it though.  The page url is relative to your
context.  So if my context was /salesweb, and i wanted the page at
/salesweb/forum/transition-.jsp  I would need to send it
/forum/transition-.jsp.  Also when I tried <jsp:include page"<%=
request.getContextPath() %>/forum/transition-.jsp"/> I would get a compile
error (this was before I figured out it was context relative), however
<jsp:include page"<%=  StringNameHere %>"/> would work.  Very odd.  I just
wish the original redirect would work, so my code doens't look all sloppy ;)
Thanks Adam,
David

----- Original Message ----- 
From: "Adam Hardy" <ah...@cyberspaceroad.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, October 30, 2003 1:30 PM
Subject: Re: Tiles Redirect Bug on a per Tile basis? Help!


> On 10/30/2003 07:01 PM David Erickson wrote:
> > Adam,
> > Essentially I just want to display a different content in that area of
my
> > layout.  And I considered using a jsp:include, but by the point the
logic
> > determines that a different page needs to be in that spot it has already
> > loaded a bunch of JSP variables and stuff into the page, by including
> > another page with variables potentially the same would it mess
everything
> > up?  Also for example was:
> >
> > if (x condition is met)
> > {
> > %>
> > <jsp:include "blah.jsp>
> > <%
> > return;
> > }
> >
> > %>
> >
> > Would that return successfully quit running any logic from my original
jsp?
>
> Regarding the variables getting messed up: there are 2 types of includes
> - I think the one you have used above would be OK. There is also the
> straight <@% include file="" %>. Again though JSP is not my forte.
>
> I'm not sure whether the return would end the JSP. A check in the
> compiled JSP file would show you. I never do too much logic in my JSPs
> so I'm not too hot on that.
>
> Perhaps you should make an else {} that encompasses the whole of the
> rest of the JSP. Horrible, but I take it you are modifying existing
> code, so it might be the easiest way.
>
> Adam
>
> -- 
> struts 1.1 + tomcat 5.0.12 + java 1.4.2
> Linux 2.4.20 RH9
>
>
> ---------------------------------------------------------------------
> 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: Tiles Redirect Bug on a per Tile basis? Help!

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
On 10/30/2003 07:01 PM David Erickson wrote:
> Adam,
> Essentially I just want to display a different content in that area of my
> layout.  And I considered using a jsp:include, but by the point the logic
> determines that a different page needs to be in that spot it has already
> loaded a bunch of JSP variables and stuff into the page, by including
> another page with variables potentially the same would it mess everything
> up?  Also for example was:
> 
> if (x condition is met)
> {
> %>
> <jsp:include "blah.jsp>
> <%
> return;
> }
> 
> %>
> 
> Would that return successfully quit running any logic from my original jsp?

Regarding the variables getting messed up: there are 2 types of includes 
- I think the one you have used above would be OK. There is also the 
straight <@% include file="" %>. Again though JSP is not my forte.

I'm not sure whether the return would end the JSP. A check in the 
compiled JSP file would show you. I never do too much logic in my JSPs 
so I'm not too hot on that.

Perhaps you should make an else {} that encompasses the whole of the 
rest of the JSP. Horrible, but I take it you are modifying existing 
code, so it might be the easiest way.

Adam

-- 
struts 1.1 + tomcat 5.0.12 + java 1.4.2
Linux 2.4.20 RH9


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


Re: Tiles Redirect Bug on a per Tile basis? Help!

Posted by David Erickson <de...@cmcflex.com>.
Adam,
Essentially I just want to display a different content in that area of my
layout.  And I considered using a jsp:include, but by the point the logic
determines that a different page needs to be in that spot it has already
loaded a bunch of JSP variables and stuff into the page, by including
another page with variables potentially the same would it mess everything
up?  Also for example was:

if (x condition is met)
{
%>
<jsp:include "blah.jsp>
<%
return;
}

%>

Would that return successfully quit running any logic from my original jsp?
Thanks,
David

----- Original Message ----- 
From: "Adam Hardy" <ah...@cyberspaceroad.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, October 30, 2003 1:14 AM
Subject: Re: Tiles Redirect Bug on a per Tile basis? Help!


> On 10/29/2003 11:52 PM David Erickson wrote:
> > Ya sorry that is a hard question.. here let me give more explanation:
> > <definition name=".Default" path="/tiles/layouts/base.jsp">
> >
> > <put name="header" value="/tiles/header.jsp"/>
> >
> > <put name="menu" value="${menu}"/>
> >
> > <put name="body" value="${body}"/>
> >
> > <put name="footer" value="/tiles/footer.jsp"/>
> >
> > <put name="logon" value="/tiles/logon.jsp"/>
> >
> > <put name="title" value="Sales Web"/>
> >
> > <put name="messages" value="/tiles/messages.jsp"/>
> >
> > </definition>
> >
> > <definition name=".Forum" extends=".Default">
> >
> > <put name="body" value="/forum/index.jsp"/>
> >
> > <put name="menu" value=".menu.Forum"/>
> >
> > </definition>
> >
> >
> >
> > These are my two tile definitions in my tiles-defs.xml file.  I call a
jsp
> > file, for example test.jsp it contains:
> >
> > <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
> >
> >
> >
> > <tiles:insert definition=".Forum" flush="true">
> >
> > <tiles:put name="body" value="/forum/test-.jsp"/>
> >
> > </tiles:insert>
> >
> > (which is basically just a way to call a definition without using a
struts
> > action for right now)
> >
> > The above fills everything into our page layout and overrides body with
> > test-.jsp.  Now test-.jsp goes into the body slot, the main area on the
> > page.  I do some logic in it and determine, before its rendered, that
the
> > user is not logged in or whatever else, and instead of it going into the
> > body area it needs to redirect to another page to fill that slot.
However
> > when I try that the body area just comes up blank.  And thats just
using:
> >
> > url = response.encodeRedirectURL(request.getContextPath() +
> > "/forum/transition.jsp");
> >
> > response.sendRedirect(url);
> >
> > return;
> >
> > I know the above redirect code works, because when I put it in a .jsp
that
> > does not includes our tiles layout it works fine.
>
> It's not clear whether you want to do a redirect to take the user to a
> different page, which is what I assumed from your first message, or
> whether you want to stay on that page and just have different content in
> your body slot.
>
> If you only need different content, why do a redirect? Why can't you
> just do a straight jsp:include?
>
> Adam
>
> -- 
> struts 1.1 + tomcat 5.0.12 + java 1.4.2
> Linux 2.4.20 RH9
>
>
> ---------------------------------------------------------------------
> 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: Tiles Redirect Bug on a per Tile basis? Help!

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
On 10/29/2003 11:52 PM David Erickson wrote:
> Ya sorry that is a hard question.. here let me give more explanation:
> <definition name=".Default" path="/tiles/layouts/base.jsp">
> 
> <put name="header" value="/tiles/header.jsp"/>
> 
> <put name="menu" value="${menu}"/>
> 
> <put name="body" value="${body}"/>
> 
> <put name="footer" value="/tiles/footer.jsp"/>
> 
> <put name="logon" value="/tiles/logon.jsp"/>
> 
> <put name="title" value="Sales Web"/>
> 
> <put name="messages" value="/tiles/messages.jsp"/>
> 
> </definition>
> 
> <definition name=".Forum" extends=".Default">
> 
> <put name="body" value="/forum/index.jsp"/>
> 
> <put name="menu" value=".menu.Forum"/>
> 
> </definition>
> 
> 
> 
> These are my two tile definitions in my tiles-defs.xml file.  I call a jsp
> file, for example test.jsp it contains:
> 
> <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
> 
> 
> 
> <tiles:insert definition=".Forum" flush="true">
> 
> <tiles:put name="body" value="/forum/test-.jsp"/>
> 
> </tiles:insert>
> 
> (which is basically just a way to call a definition without using a struts
> action for right now)
> 
> The above fills everything into our page layout and overrides body with
> test-.jsp.  Now test-.jsp goes into the body slot, the main area on the
> page.  I do some logic in it and determine, before its rendered, that the
> user is not logged in or whatever else, and instead of it going into the
> body area it needs to redirect to another page to fill that slot.  However
> when I try that the body area just comes up blank.  And thats just using:
> 
> url = response.encodeRedirectURL(request.getContextPath() +
> "/forum/transition.jsp");
> 
> response.sendRedirect(url);
> 
> return;
> 
> I know the above redirect code works, because when I put it in a .jsp that
> does not includes our tiles layout it works fine.

It's not clear whether you want to do a redirect to take the user to a 
different page, which is what I assumed from your first message, or 
whether you want to stay on that page and just have different content in 
your body slot.

If you only need different content, why do a redirect? Why can't you 
just do a straight jsp:include?

Adam

-- 
struts 1.1 + tomcat 5.0.12 + java 1.4.2
Linux 2.4.20 RH9


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


Re: Tiles Redirect Bug on a per Tile basis? Help!

Posted by David Erickson <de...@cmcflex.com>.
Ya sorry that is a hard question.. here let me give more explanation:
<definition name=".Default" path="/tiles/layouts/base.jsp">

<put name="header" value="/tiles/header.jsp"/>

<put name="menu" value="${menu}"/>

<put name="body" value="${body}"/>

<put name="footer" value="/tiles/footer.jsp"/>

<put name="logon" value="/tiles/logon.jsp"/>

<put name="title" value="Sales Web"/>

<put name="messages" value="/tiles/messages.jsp"/>

</definition>

<definition name=".Forum" extends=".Default">

<put name="body" value="/forum/index.jsp"/>

<put name="menu" value=".menu.Forum"/>

</definition>



These are my two tile definitions in my tiles-defs.xml file.  I call a jsp
file, for example test.jsp it contains:

<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>



<tiles:insert definition=".Forum" flush="true">

<tiles:put name="body" value="/forum/test-.jsp"/>

</tiles:insert>

(which is basically just a way to call a definition without using a struts
action for right now)

The above fills everything into our page layout and overrides body with
test-.jsp.  Now test-.jsp goes into the body slot, the main area on the
page.  I do some logic in it and determine, before its rendered, that the
user is not logged in or whatever else, and instead of it going into the
body area it needs to redirect to another page to fill that slot.  However
when I try that the body area just comes up blank.  And thats just using:

url = response.encodeRedirectURL(request.getContextPath() +
"/forum/transition.jsp");

response.sendRedirect(url);

return;

I know the above redirect code works, because when I put it in a .jsp that
does not includes our tiles layout it works fine.

Help!

-David

----- Original Message ----- 

From: "Adam Hardy" <ah...@cyberspaceroad.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, October 29, 2003 3:43 PM
Subject: Re: Tiles Redirect Bug on a per Tile basis? Help!


> On 10/29/2003 11:04 PM David Erickson wrote:
> > Bug description:
> > Using tiles to handle our webpage.  I have an individual tile which is a
jsp
> > that does some logic on our forums, if a certain situation occurs that
tile
> > when loaded will attempt to redirect to a error page.  However this does
not
> > work.  Instead where that tile should be it just comes up blank.  I have
> > also tried getting the request dispatcher and forwarding if that error
> > occurs but it says that the response has been commited and throws an
> > exception..  so how in the world am I supposed to insert a different
page
> > there if this condition comes up!
>
> That is a demanding question. The problem is that the outer-most Tile
> controls its child Tiles. This is a complete stab in the dark but try
> writing the redirect URL into the request attributes, and then at the
> end of the outermost Tile, check to see if there is a non-null value,
> and if so, do the redirect there.
>
> Adam
>
>
> -- 
> struts 1.1 + tomcat 5.0.12 + java 1.4.2
> Linux 2.4.20 RH9
>
>
> ---------------------------------------------------------------------
> 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: Tiles Redirect Bug on a per Tile basis? Help!

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
On 10/29/2003 11:04 PM David Erickson wrote:
> Bug description:
> Using tiles to handle our webpage.  I have an individual tile which is a jsp
> that does some logic on our forums, if a certain situation occurs that tile
> when loaded will attempt to redirect to a error page.  However this does not
> work.  Instead where that tile should be it just comes up blank.  I have
> also tried getting the request dispatcher and forwarding if that error
> occurs but it says that the response has been commited and throws an
> exception..  so how in the world am I supposed to insert a different page
> there if this condition comes up!

That is a demanding question. The problem is that the outer-most Tile 
controls its child Tiles. This is a complete stab in the dark but try 
writing the redirect URL into the request attributes, and then at the 
end of the outermost Tile, check to see if there is a non-null value, 
and if so, do the redirect there.

Adam


-- 
struts 1.1 + tomcat 5.0.12 + java 1.4.2
Linux 2.4.20 RH9


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