vendredi 15 juillet 2016

JSP check if variable exist in include page

Background: I am very new to JSP.

Question: I have two pages partent.jsp and child.jsp. I am going to set a variable in parent.jsp

<c:set var="dept-accordion" value="true"/>

I am then going to include child.jsp into parent.jsp

<%@ include file="/includes/child.jsp"%>

(Child.jsp is also used as an included in other files) But I want to check to see if the page child.jsp is being included into is parent.jsp by checking to see if the dept-accorion variable is set. This would work best if it was in an if-statement since I am going to show something different if it is or isn't parent.jsp

Example of child.jsp (what I have so far)

<c:if dept-accordion="$true">

<div class="accordion-body dept-accordion" style="display:block;" aria-labelledby="tab${statusCount}" role="tabpanel" aria-selected="false" aria-expanded="false" id="panel${statusCount}">
<c:/if>

<c:if dept-accordion does not exist>   

        <div class="accordion-body"  aria-labelledby="tab${statusCount}" role="tabpanel" aria-selected="false" aria-expanded="false" id="panel${statusCount}">
 <c:/if>

Aucun commentaire:

Enregistrer un commentaire