0

In my application I am trying to do a pageContext include in a custom tag java file. I am going to include a jsp file.

Can I pass any parameters to the jsp file which would be scoped only to the file(like params passed in jsp:include)?

I am aware that I can set it as an attribute in the request and use it in the jsp, however I don't think this is the best solution as I do not want it to persist in the request. Besides, the jsp file may in turn use the same tag again, which would override this attribute, and the rest of the jsp would have the wrong attribute.

Here is the code for that:

request.setAttribute("myVariable", this.viewletId);

pageContext.include(viewletLayout);

Is there a way to pass it to just the jsp in its scope(Like jsp:include)?

Bulbasaur
  • 696
  • 1
  • 14
  • 22

1 Answers1

-1

Look here to get the solution that hinted me to what worked for me:

    <% 
        if ("layout1".equalsIgnoreCase(viewletLayout)){
            %><%@include file="layout1.jsp"%><%
        } else if ("layout2".equalsIgnoreCase(viewletLayout)){
            %><%@include file="layout2.jsp"%><%
        }
    %>
Neepsnikeep
  • 309
  • 3
  • 11