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

  • Home
  • SEARCH
  • 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 221815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:04:08+00:00 2026-05-11T19:04:08+00:00

What are the scoping rules for variables in a jsp page with pages added

  • 0

What are the scoping rules for variables in a jsp page with pages added to them using tags?

My understanding is that an included page is essentially copied verbatim into the page, which would lead me to assume that if I’ve declared a variable in a Parent JSP that it would be available in the child ones.

However Eclipse complains about this (understandably because I could feasibly include the pages in any page or use them as stand alone. And when I try to start the tomcat server it fails to start.

I basically want to get a couple of variables from the session in the parent page and use them in the child pages. This doesn’t work.

So I’ve struck ont he idea of getting them from the session in each of the child pages, however I was wondering if I could give them all the same variable names, or if I’d have to pick different variable names for them in each page so they didn’t clash.

Also what about imports if I import log4net in the parent jss do I also have to import it in the child ones?

  • 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-11T19:04:08+00:00Added an answer on May 11, 2026 at 7:04 pm

    In JSP there are two ways of including other jsp pages.

    <%@include file="include.jsp"%>
    

    and

    <jsp:include page="include.jsp" />
    

    If you use the former, then any variable declared on the parent JSP will be in scope in the include.jsp (of course Eclipse will not see this as you surmised) as it is effectively copied in by the compiler.

    If you use the second approach, the inclusion is done at runtime and the include page has its own scope.

    Ditto for imports. Although it is safe to redundantly import them in the include page.

    If I’m using the former I prefer to suffix them with .jspf to signify a JSP fragment. I can than turn off some of Eclipses warning in the fragment files. But in general I try to avoid using that method and prefer the second approach.

    More information can be found in the docs here: Include directive and JSP include.

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

Sidebar

Ask A Question

Stats

  • Questions 274k
  • Answers 274k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try this: WITH t AS ( SELECT Checkintime, DeviceID, rn… May 13, 2026 at 2:26 pm
  • Editorial Team
    Editorial Team added an answer You should import it in the utilpackage module, but only… May 13, 2026 at 2:26 pm
  • Editorial Team
    Editorial Team added an answer Is there some horrible problem with window.open(asoRequestURL);? I know it's… May 13, 2026 at 2:26 pm

Related Questions

What exactly are the Python scoping rules? If I have some code: code1 class
What are the scoping rules for transaction isolation levels in SQL Server 2005? I
I believe I'm getting bitten by some combination of nested scoping rules and list
What guidelines do you follow to improve the general quality of your code? Many

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.