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 6331113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:59:46+00:00 2026-05-24T17:59:46+00:00

If I do: <% pageContext.setAttribute(foo, bar); %> <custom:myTag/> it seems like I should be

  • 0

If I do:

<% pageContext.setAttribute("foo", "bar"); %>
<custom:myTag/>

it seems like I should be able to do:

<%= pageContext.getAttribute("foo") %>

inside of myTag.tag … but of course I can’t because the tag file doesn’t have access to the pageContext (instead it has access to a jspContext … which doesn’t have the same attributes as the calling page’s pageContext).

Now, you can access the pageContext via ELScript:

${pageContext}

but that doesn’t help because ELScript has no way of passing arguments, so you can’t do:

${pageContext.getAttribute("foo")}

However, the fact that ELscript can accesss the page context, and the fact that the tag can access all sorts of variables like jspContext, that there must be some way for a tag to access (in a scriptlet/Java logic way, not just in ELScript) an attribute from the calling JSP’s pageContext.

Is there?

  • 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-24T17:59:47+00:00Added an answer on May 24, 2026 at 5:59 pm

    As to EL, the ${pageContext.getAttribute("foo")} works in EL 2.2 only. Before that the right syntax is ${pageContext.foo} or just ${foo}. See also our EL wiki page.

    However, the ${pageContext} isn’t shared between the parent JSP file and the JSP tag. Each has its own instance.

    You could either set it as request attribute instead:

    <% request.setAttribute("foo", "bar") %>
    <custom:myTag />
    

    with in the tag

    <%= request.getAttribute("foo") %>
    

    or, with EL

    ${requestScope.foo}
    

    or

    ${foo}
    

    Or, better, you could pass it as a fullworthy tag attribute

    <custom:myTag foo="bar" />
    

    with in the tag

    <%@attribute name="foo" required="true" %>
    ${pageContext.foo}
    

    or just

    <%@attribute name="foo" required="true" %>
    ${foo}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to write a custom JSP tag whose output includes other JSP
Why would the pageContext variable not be findable in this custom tag installed in
I've got some EL code inside of a JSP tag. The line starts as
i wrote custom tag which makes it easy to localize strings; in jsp it
When trying to use a custom JSP tag library, I have a variable defined
I am hitting a URL in a JSP thru the tag: <'c:import url=${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}/${pageContext.request.contextPath}/html/temp.html var=content
How can I add jspf file to jsp page via custom tag? In the
I'm sending the request from Display.jsp to TrialShow.jsp page, but whenever I call ${pageContext.request.requestURL}
Is it possible to write a custom JSP tag to take an i18n message
I'm trying to access the servlet path from a tag file like so; <%@tag

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.