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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:28:23+00:00 2026-05-26T04:28:23+00:00

I am using Spring 2.5 in my application. In the view I have main

  • 0

I am using Spring 2.5 in my application. In the view I have main jsp in which I have included another jsp. I have declared a variable using c:set tag in main jsp which I can not access inside the jsp. Below is code
main.jsp

<c:set var="hPediquestStudy"><spring:message code="study.hpediquest.mapping" /></c:set>
<c:set var="currentStudy" value='<%=(String)session.getAttribute("currentStudy")%>'/>
<html>
<head>
</head>
<body>
<c:if test="${currentStudy eq hPediquestStudy}">
  Variables are equal
</c:if>
<c:if test="${currentStudy ne hPediquestStudy}">
  Variables are not equal
</c:if>
<jsp:include page="/WEB-INF/jsp/included.jsp"></jsp:include>
</body
</html>

included.jsp

<c:if test="${currentStudy eq hPediquestStudy}">
   hPediquestStudy Variable is accessible
</c:if>
 <br/>currentStudy : ${currentStudy}
 <br/>hPediquestStudy : ${hPediquestStudy}

I am getting output

Variables are equal

currentStudy : hPediquest

hPediquestStudy :

  1. Why on main jsp both values are equal while in included jsp I dont see its value?
  2. Why currentStudy displays its value inside the included jsp?
  3. is there any solution which helps me to access the variable set in the parent jsp ans can be accessed in the included jsps?

I can see the value of hPediquestStudy value if I set that variable in included jsp like in main jsp. But I dont want to set it every time when I include the jsp. Please help

  • 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-26T04:28:24+00:00Added an answer on May 26, 2026 at 4:28 am

    Why on main jsp both values are equal while in included jsp I dont see its value?

    Because <c:set> by default stores them in the page scope.


    Why currentStudy displays its value inside the included jsp?

    Because it’s available as session attribute as well.


    is there any solution which helps me to access the variable set in the parent jsp ans can be accessed in the included jsps?

    You need to set the scope attribute of <c:set> to request or above. The (default) page scope is exposed to current JSP only, not any included JSPs.


    Note that the line

    <c:set var="currentStudy" value='<%=(String)session.getAttribute("currentStudy")%>'/> 
    

    is unnecessary. The ${currentStudy} will already scan for variables in page, request, session and application scopes. As you’ve apparently already set it in the session scope, you don’t need to copy it into the page scope. So, just remove that line. All with all, your top 2 <c:set> lines should be replaced with this single line:

    <c:set var="hPediquestStudy" scope="request"><spring:message code="study.hpediquest.mapping" /></c:set>
    

    and then it’ll work the way you intended.

    See also:

    • Our EL wiki page
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a spring MVC application using JSP as my view technologies with Jquery
I have this web application using Spring Web Flow framework. In my main page
I'm using Spring's form tag library in a Spring MVC application that I am
Hey I am developing an desktop application using Spring and Hibernate, and I have
I have a webapp which is built using spring 3 and tiles 2 (not
I have a Java web application using spring web flow. How do I pass
I am using Spring Web MVC for my application. I have 1 dropdown list
I am using Spring MVC to build my web application, and I have a
I have just written a Word Document creation web application using .NET 3.5 which
I have set up i18n to my web app using Spring.It works fine.But I

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.