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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:15:11+00:00 2026-05-16T21:15:11+00:00

When we can access all the implicit variables in JSP, why do we have

  • 0

When we can access all the implicit variables in JSP, why do we have pageContext ?

My assumption is the following: if we use EL expressions or JSTL, to access or set the attributes we need pageContext. Let me know whether I am right.

  • 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-16T21:15:11+00:00Added an answer on May 16, 2026 at 9:15 pm

    You need it to access non-implicit variables. Does it now make sense?


    Update: Sometimes would just like to access the getter methods of HttpServletRequest and HttpSession directly. In standard JSP, both are only available by ${pageContext}. Here are some real world use examples:


    Refreshing page when session times out:

    <meta http-equiv="refresh" content="${pageContext.session.maxInactiveInterval}">
    

    Passing session ID to an Applet (so that it can communicate with servlet in the same session):

    <param name="jsessionid" value="${pageContext.session.id}">
    

    Displaying some message only on first request of a session:

    <c:if test="${pageContext.session['new']}">Welcome!</c:if>
    

    note that new has special treatment because it’s a reserved keyword in EL, at least, since EL 2.2


    Displaying user IP:

    Your IP is: ${pageContext.request.remoteAddr}

    Making links domain-relative without hardcoding current context path:

    <a href="${pageContext.request.contextPath}/login">login</a>
    

    Dynamically defining the <base> tag (with a bit help of JSTL functions taglib):

    <base href="${fn:replace(pageContext.request.requestURL, pageContext.request.requestURI, pageContext.request.contextPath)}/">
    

    Etcetera. Peek around in the aforelinked HttpServletRequest and HttpSession javadoc to learn about all those getter methods. Some of them may be useful in JSP/EL as well.

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

Sidebar

Related Questions

I have implemented You-tube API in asp.net 4.0 application.I can access all other parameter
I am aware that I can access all external links on a page using
How can i block all access to a php file using mod_sec? The file
Possible Duplicate: How can I access local scope dynamically in javascript? Hi all. We
In database.yml you define all the settings. How can I access those settings from
I'm a java developer new to python. In java, you can access all classes
In a DataTable : I can access all of the DataRow elements like so:
Confirm Installation - It can access: -All data on your computer and the websites
I am making a desktop yellowpage application. I can access all countries yellowpage site
Am trying to parse the RSS feed from www.ted.com/talks/rss, I can access all normal

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.