Pass page scope attributes to a JSP using pagecontext.include for use in JSTL?

Posted by hal10001 on Stack Overflow See other posts from Stack Overflow or by hal10001
Published on 2010-05-10T20:11:12Z Indexed on 2010/05/10 20:14 UTC
Read the original article Hit count: 195

Filed under:
|
|
|

We're using this JSP template solution almost verbatim at work:

http://java.sun.com/developer/technicalArticles/javaserverpages/jsp_templates/

When it gets JSP pages to be included, it uses pageContext.include, which leaves us with one problem, and that is that we have a lot of scriplet code that gets initialized in the JSP itself (tag soup). My thought was to modify the template tag with an additional attribute that is a package path reference to a class with an init or execute method. That execute would get called first, and would add page context attributes before including the JSP. We would then use JSTL to access those attributes. However, I was told this wouldn't work because of how pageContext.include works, and the inability to pass through attributes scoped to the page. Is that true, and are there workarounds? I'm so-so on knowing all my scoping rules.

© Stack Overflow or respective owner

Related posts about jsp

Related posts about page