Search code examples
javajspjsp-tags

how to use variable in page attribute of jsp include tag?


how to use variable in page attribute of jsp include tag ?

<jsp:include page="/adminadvertisement?type=c80&action=showall" /> 

I want to insert a variable passed as parameter in page attribute .Something like

<jsp:include page="/adminadvertisement?type={$param.type}&action=showall" />

Solution

  • Use <jsp:param> (and fix your incorrect EL expression, it should follow ${} syntax)

    <jsp:include page="/adminadvertisement">
        <jsp:param name="type" value="${param.type}" />
        <jsp:param name="action" value="showall" />
    </jsp:include>
    

    However, since it's to be derived from the request parameter, you should be able to use ${param.type} inside the included JSP page page directly without passing it as <jsp:param>.