Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 993081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:21:51+00:00 2026-05-16T06:21:51+00:00

One of the things that has always bothered me about <jsp:include..> is that it’s

  • 0

One of the things that has always bothered me about <jsp:include..> is that it’s not possible to pass non-String values into the included page as distinct inputs to the page. For example, I’d like to be able to do the following:

<c:forEach var="item" items="${listOfItems}">
    <jsp:include page="mypage.jsp">
        <jsp:attribute name="item" value="${item}/>
    </jsp:include>
</c:forEach>

The idea being that, by declaring the item being passed in as an attribute inside the jsp:include node, the code is making it clear what the intent was… to supply that parameter to the included page.

The only mechanism currently available for doing this is to define the attribute “globally”, and then let the included page read it from the global space. Unfortunately, this looses that same “intent” that using <jsp:param> provides. Additionally, it makes the code harder to debug, for the same reason that globals in any programming environment do.

Does anyone know of an implementation of an include mechanism that performs the functions of jsp:include, but allows for passing in non-String values? Or, if not, I’d be open to alternative ideas that preserve the same goal of intent and ease of debugging.

As a side note, I’d love to see a builtin “catch” mechanism for when the included page throws an error:

<abc:include page="mypage">
    <abc:param name="something" value="some string value"/>
    <abc:attribute name="somethingelse" value="${nonStringValue}"/>
    <abc:catch var="ex">
        The page failed, so the content it generated will not be sent to the output
        stream. Instead, we can collapse the part of the page that it's content
        would be... possibly putting a comment in the page with
        <!-- There was an exception generating this module: 
             <c:out value="${ex.getMessage}/>
          -->
    </abc:catch>
</abc:include>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:21:52+00:00Added an answer on May 16, 2026 at 6:21 am

    Having read the answers here, plus doing additional research on the subject, I’ve come up with the following:

    • You can serialize your objects then deserialize them in the included JSP. Not a fan of this because it makes the code more complex (every object you pass in must be serializable, etc)
    • You can use taglibs. Not a fan of this, since I feel they serve a different role than JSP include files
    • You can define the variables at the request scope, which will make them available to the included JSP. Not a big fan of this since it doesn’t show the intent of the programmer (passing in the values to the included page, for it’s use only).
    • There really isn’t (that I could find) an implementation that achieves what I’m looking for, but it is possibly to build something that comes close via custom tags.

    I did some work and put together the code to achieve what I was looking for, and then threw it up on sourceforge. It allows you to specify the inputs in the way I was describing:

    <inc:include page="normal.jsp">
        <inc:param name="param1" value="param1value" />
        <inc:param name="param2" value="param2value" />
        <inc:attrib name="attrib1" value="${attrib1value}" />
        <inc:attrib name="attrib2" value="${attrib2value}" />
        <inc:catch var="ex">
           This block was not rolled up because there wasn't an error. 
           Should never see this, but just in case, the exception was: ${ex.message}
        </inc:catch>
    </inc:include>
    

    The only problem with it (at this time) is that I add the attributes to the request scope before the page is included, then remove them after (or reset them if they already existed). What I’d like to do, instead, is wrap the request object instead and override the attribute methods to automatically include the values passed in… I’m still working on that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This one of the things that has always bothered me about Matlab. I understand
One of the things that has been talked about a few times on the
I am relatively new to Xcode and one thing that has bothered me is
One of the first things I learned in C++ was that #include <iostream> int
One of the most difficult things about understand Spring is that Spring supports multiple
One of the nice things about MooTools, is that it lets you easily assign/fire
One thing that bothers me about nHibernate is that it is not 100% compile
One thing that has driven me nuts about SharePoint2007 is the apparent inability to
One of the things that always stumbles me when working with WPF is the
i notice one nice things that a amazon provide that is load pdf data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.