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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:01:03+00:00 2026-05-27T06:01:03+00:00

I have a hashmap which is stored in a session. The hashMap is a

  • 0

I have a hashmap which is stored in a session. The hashMap is a map of maps.

HashMapStoredInSession ={"290" = {text="abc", response="someText"}, "276"={text="xyz", response="random"}};  

I dont want to use scriptlets. But I am stuck with one scriptlet and cant seem to make it work. Any suggestions where I am going wrong would be great.
The following combination of SCRIPTLET + JSTL works

Scriptlet:

<%     
    Map hMap= (Map)request.getSession().getAttribute("HashMapStoredInSession");   
    pageContext.setAttribute("mapofMaps", hMap);  
%>  

JSTL code:

<c:if test="${param.ID != 'null' && not empty param.ID}">   
    <c:set var="someID" value="${param.ID}" scope="session"/>  
</c:if>  
<c:forEach items="${mapofMaps}" var="outerMap">             
    <c:if test="${outerMap.key == someID}">    // this is the line where exception is thrown when the above scriptlet code is replaced with JSTL below                  
        <c:forEach items="${outerMap.value}" var="innerMap">                    
            <c:if test="${innerMap.key == 'param1'}">  
                <c:set var="response1" value="${innerMap.value}"/>  
            </c:if>  
            <c:if test="${innerMap.key == 'param2'}">  
                <c:set var="response2" value="${innerMap.value}"/>  
            </c:if>              
        </c:forEach>  
    </c:if>  
</c:forEach>  

Now if I try to replace scriptlet code with following( with no change in JSTL code)

<c:set var="mapofMaps" value ='<c:out value ="<%=request.getSession().getAttribute("HashMapStoredInSession")%>"/>'/>  

I get the following error

An error occurred while evaluating custom action attribute "test" with value "${outerMap.key == someID}":   
Unable to find a value for "key" in object of class "java.lang.String" using operator "." (null) 
  • 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-27T06:01:04+00:00Added an answer on May 27, 2026 at 6:01 am

    You can just reference it by ${HashMapStoredInSession}.

    <c:forEach items="${HashMapStoredInSession}" var="outerMap">             
    

    Or if you really want to rename the attribute name, do so:

    <c:set var="mapofMaps" value="${HashMapStoredInSession}" />  
    

    The key is that EL ${} already lookups for attributes in page, request, session and application scopes. So you don’t need to explicitly use session.getAttribute() by a scriptlet.

    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 HashMap called examList which stored exam grades of each course a
I have data stored in a HashMap, which I want to access via multiple
I have HashMap 1, which contains 5 keys, all of which have Hashmaps as
If I have the value foo , and a HashMap<String> ftw for which ftw.containsValue(foo)
i have a hashmap where every key has many values(stored in a arraylist). How
I have this HashMap: HashMap<String, Integer> m which basically stores any word (String) and
We have a collection which stores a Map as an embedded collection. We need
I have a vector which contains a list of Hash maps in Clojure and
I have a convenience collection class in my Flex project called HashMap, which is
I have a custom model, which internally uses HashMap<String, Object> to store the 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.