[thelist] JSP question
Hassan Schroeder
hassan at webtuitive.com
Tue Oct 21 09:35:37 CDT 2003
Tom Dell'Aringa wrote:
> I have an include that includes some DIVs that are conditional.
> I want to show one DIV based on some set variable.
> end up getting a cannot resolve symbol error. Here is what I had
> tried in JSP:
>
> <% String orderInfo = "1"; %>
> // below is the page with the conditional DIV indside..
> <jsp:include page="includes/dashboards.jsp"/>
>
> inside the "dashboards.jsp" page I tried this:
>
> <% if(orderInfo.equals("1"))...show DIV %> (psuedo)
>
> Which does not work.
It doesn't work because you've set 'orderInfo' within a PageContext,
and `dashboards.jsp` has its own PageContext -- everything in it is
evaluated *before* being including.
However, both pages are part of one *request*, though, so you can do:
<%
String orderInfo = "1";
request.setAttribute("orderInfo", orderInfo);
/* you could combine those two statements, of course */
%>
<jsp:include page="dashboards.jsp"/>
Then in dashboards.jsp:
<%
if ( request.getAttribute("orderInfo").equals("1") )
{
%>
conditional content goes here ....
<%
}
%>
HTH!
--
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design === (+1) 408-938-0567 === http://webtuitive.com
dream. code.
More information about the thelist
mailing list