Fetch Map value from session inside Struts JSPSort a Map<Key, Value> by valuesHow to get an enum value from a string value in Java?Passing Value in Struts 2 from JSP to JSPSetting check boxes on JSPHow to send an object as check-box value from the checked row to Struts 2 actionSession value not displaying in jsp struts 2How to add the checkbox value temporary storage and put it in session obj using Struts 2To add the result set values from the servlet to the check box in jsptextbox value in JSP to Java scriptlet code in the same JSP

When calculating averages, why can we treat exploding die as if they're independent?

Features seen on the Space Shuttle's solid booster; what does "LOADED" mean exactly?

Change-due function

How to say "In Japan, I want to ..."?

Friend is very nitpicky about side comments I don't intend to be taken too seriously

Are personality traits, ideals, bonds, and flaws required?

What makes things real?

Why is it that I have to play this note on the piano as A sharp?

Python implementation of atoi

is it possible to change a material depending on whether it is intersecting with another object?

How strong is aircraft-grade spruce?

Bacteria vats to generate edible biomass, require intermediary species?

How to improvise or make pot grip / pot handle

The Green Glass Door, Revisited

Write a Schrödinger's sentence

Complex conjugate and transpose "with respect to a basis"

Yet another calculator problem

A question regarding Buddhist world view and sense organs and their objects

What is the purpose of the rotating plate in front of the lock?

Are professors obligated to accept supervisory role? If not, how does it work?

Automatically end list item with proper punctuation (semicolon, period)

After a few interviews, What should I do after told to wait?

Is there any control character or hack to prevent simple command line tools from showing subsequent data?

Is there a specific way to describe over-grown, old, tough vegetables?



Fetch Map value from session inside Struts JSP


Sort a Map<Key, Value> by valuesHow to get an enum value from a string value in Java?Passing Value in Struts 2 from JSP to JSPSetting check boxes on JSPHow to send an object as check-box value from the checked row to Struts 2 actionSession value not displaying in jsp struts 2How to add the checkbox value temporary storage and put it in session obj using Struts 2To add the result set values from the servlet to the check box in jsptextbox value in JSP to Java scriptlet code in the same JSP






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have a session variable(it is a map with the structure Map<String,ArrayList<String>>) in JSP.
When i print the value in the console like
<%System.out.println("Session Value "+session.getAttribute("PRODUCTTYPESTEMP"));%> it is printing the entire value in the console.
All I want is to get the ArrayList value by passing the desired key and get it printed with check box.
I am not sure how to do this.
BTW I am not familiar with struts or JSP.
Any help is much appreciated.



For reference, Below is the existing piece of code(please ignore , if its confusing, please provide a way to achieve the above mentioned functionality ) - Which will work if the session returns ArrayList , I am trying to rewrite it for map by passing desired key.






<input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
<ul class="nested">
<li>
<label><input type="checkbox" /><span></span></label>Warrants
</li>
<% colCntr=0; %>
<s:iterator var="product_types" value="#session['PRODUCTTYPESTEMP']">
<li>
<label>
<input type="checkbox" id="productTypeCodesTemp" name="productTypeCodesTemp" value="<s:property value="#product_types_temp.value"/>"
<s:iterator var="productTypeTemp" value="#attr['productTypeCodesTemp']">
<s:if test="%#attr['productType']==#product_types.value"> checked="checked" </s:if>
</s:iterator>/>
<span></span></label>
<s:property value="#product_types.label"/>
</li>
</s:iterator>
</ul>





Edit -
Added new code with the help of Madis R






<li class="caret">
<input type="checkbox" id="warrantsCb" checked="checked" /><label>
<input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
<s:iterator value="#session['PRODUCTTYPESTEMP']">
<s:property value="Baskets"/>
<s:checkboxlist name="checkboxes" list="value"/>
</s:iterator>
</li>





The above is printing all the values with check boxes.
I need to pick only the ArrayList values associated with the key "Baskets"



Edit:
After implementing the latest solution , value is being fetched but check boxes are not available. I should align Warrant like 'Unknown' in the screen shot and the code






<td style="text-align:left;vertical-align:top;padding:0">
<div class="acidjs-css3-treeview">
<ul>
<li class="caret">
<input type="checkbox" id="warrantsCb" checked="checked" /><label>
<input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
<s:checkboxlist name="checkboxes" list="#session['PRODUCTTYPESTEMP']['Baskets']"/>
</li>
</ul>
</div>
</td>





enter image description here










share|improve this question
































    0















    I have a session variable(it is a map with the structure Map<String,ArrayList<String>>) in JSP.
    When i print the value in the console like
    <%System.out.println("Session Value "+session.getAttribute("PRODUCTTYPESTEMP"));%> it is printing the entire value in the console.
    All I want is to get the ArrayList value by passing the desired key and get it printed with check box.
    I am not sure how to do this.
    BTW I am not familiar with struts or JSP.
    Any help is much appreciated.



    For reference, Below is the existing piece of code(please ignore , if its confusing, please provide a way to achieve the above mentioned functionality ) - Which will work if the session returns ArrayList , I am trying to rewrite it for map by passing desired key.






    <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
    <ul class="nested">
    <li>
    <label><input type="checkbox" /><span></span></label>Warrants
    </li>
    <% colCntr=0; %>
    <s:iterator var="product_types" value="#session['PRODUCTTYPESTEMP']">
    <li>
    <label>
    <input type="checkbox" id="productTypeCodesTemp" name="productTypeCodesTemp" value="<s:property value="#product_types_temp.value"/>"
    <s:iterator var="productTypeTemp" value="#attr['productTypeCodesTemp']">
    <s:if test="%#attr['productType']==#product_types.value"> checked="checked" </s:if>
    </s:iterator>/>
    <span></span></label>
    <s:property value="#product_types.label"/>
    </li>
    </s:iterator>
    </ul>





    Edit -
    Added new code with the help of Madis R






    <li class="caret">
    <input type="checkbox" id="warrantsCb" checked="checked" /><label>
    <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
    <s:iterator value="#session['PRODUCTTYPESTEMP']">
    <s:property value="Baskets"/>
    <s:checkboxlist name="checkboxes" list="value"/>
    </s:iterator>
    </li>





    The above is printing all the values with check boxes.
    I need to pick only the ArrayList values associated with the key "Baskets"



    Edit:
    After implementing the latest solution , value is being fetched but check boxes are not available. I should align Warrant like 'Unknown' in the screen shot and the code






    <td style="text-align:left;vertical-align:top;padding:0">
    <div class="acidjs-css3-treeview">
    <ul>
    <li class="caret">
    <input type="checkbox" id="warrantsCb" checked="checked" /><label>
    <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
    <s:checkboxlist name="checkboxes" list="#session['PRODUCTTYPESTEMP']['Baskets']"/>
    </li>
    </ul>
    </div>
    </td>





    enter image description here










    share|improve this question




























      0












      0








      0








      I have a session variable(it is a map with the structure Map<String,ArrayList<String>>) in JSP.
      When i print the value in the console like
      <%System.out.println("Session Value "+session.getAttribute("PRODUCTTYPESTEMP"));%> it is printing the entire value in the console.
      All I want is to get the ArrayList value by passing the desired key and get it printed with check box.
      I am not sure how to do this.
      BTW I am not familiar with struts or JSP.
      Any help is much appreciated.



      For reference, Below is the existing piece of code(please ignore , if its confusing, please provide a way to achieve the above mentioned functionality ) - Which will work if the session returns ArrayList , I am trying to rewrite it for map by passing desired key.






      <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
      <ul class="nested">
      <li>
      <label><input type="checkbox" /><span></span></label>Warrants
      </li>
      <% colCntr=0; %>
      <s:iterator var="product_types" value="#session['PRODUCTTYPESTEMP']">
      <li>
      <label>
      <input type="checkbox" id="productTypeCodesTemp" name="productTypeCodesTemp" value="<s:property value="#product_types_temp.value"/>"
      <s:iterator var="productTypeTemp" value="#attr['productTypeCodesTemp']">
      <s:if test="%#attr['productType']==#product_types.value"> checked="checked" </s:if>
      </s:iterator>/>
      <span></span></label>
      <s:property value="#product_types.label"/>
      </li>
      </s:iterator>
      </ul>





      Edit -
      Added new code with the help of Madis R






      <li class="caret">
      <input type="checkbox" id="warrantsCb" checked="checked" /><label>
      <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
      <s:iterator value="#session['PRODUCTTYPESTEMP']">
      <s:property value="Baskets"/>
      <s:checkboxlist name="checkboxes" list="value"/>
      </s:iterator>
      </li>





      The above is printing all the values with check boxes.
      I need to pick only the ArrayList values associated with the key "Baskets"



      Edit:
      After implementing the latest solution , value is being fetched but check boxes are not available. I should align Warrant like 'Unknown' in the screen shot and the code






      <td style="text-align:left;vertical-align:top;padding:0">
      <div class="acidjs-css3-treeview">
      <ul>
      <li class="caret">
      <input type="checkbox" id="warrantsCb" checked="checked" /><label>
      <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
      <s:checkboxlist name="checkboxes" list="#session['PRODUCTTYPESTEMP']['Baskets']"/>
      </li>
      </ul>
      </div>
      </td>





      enter image description here










      share|improve this question
















      I have a session variable(it is a map with the structure Map<String,ArrayList<String>>) in JSP.
      When i print the value in the console like
      <%System.out.println("Session Value "+session.getAttribute("PRODUCTTYPESTEMP"));%> it is printing the entire value in the console.
      All I want is to get the ArrayList value by passing the desired key and get it printed with check box.
      I am not sure how to do this.
      BTW I am not familiar with struts or JSP.
      Any help is much appreciated.



      For reference, Below is the existing piece of code(please ignore , if its confusing, please provide a way to achieve the above mentioned functionality ) - Which will work if the session returns ArrayList , I am trying to rewrite it for map by passing desired key.






      <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
      <ul class="nested">
      <li>
      <label><input type="checkbox" /><span></span></label>Warrants
      </li>
      <% colCntr=0; %>
      <s:iterator var="product_types" value="#session['PRODUCTTYPESTEMP']">
      <li>
      <label>
      <input type="checkbox" id="productTypeCodesTemp" name="productTypeCodesTemp" value="<s:property value="#product_types_temp.value"/>"
      <s:iterator var="productTypeTemp" value="#attr['productTypeCodesTemp']">
      <s:if test="%#attr['productType']==#product_types.value"> checked="checked" </s:if>
      </s:iterator>/>
      <span></span></label>
      <s:property value="#product_types.label"/>
      </li>
      </s:iterator>
      </ul>





      Edit -
      Added new code with the help of Madis R






      <li class="caret">
      <input type="checkbox" id="warrantsCb" checked="checked" /><label>
      <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
      <s:iterator value="#session['PRODUCTTYPESTEMP']">
      <s:property value="Baskets"/>
      <s:checkboxlist name="checkboxes" list="value"/>
      </s:iterator>
      </li>





      The above is printing all the values with check boxes.
      I need to pick only the ArrayList values associated with the key "Baskets"



      Edit:
      After implementing the latest solution , value is being fetched but check boxes are not available. I should align Warrant like 'Unknown' in the screen shot and the code






      <td style="text-align:left;vertical-align:top;padding:0">
      <div class="acidjs-css3-treeview">
      <ul>
      <li class="caret">
      <input type="checkbox" id="warrantsCb" checked="checked" /><label>
      <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
      <s:checkboxlist name="checkboxes" list="#session['PRODUCTTYPESTEMP']['Baskets']"/>
      </li>
      </ul>
      </div>
      </td>





      enter image description here






      <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
      <ul class="nested">
      <li>
      <label><input type="checkbox" /><span></span></label>Warrants
      </li>
      <% colCntr=0; %>
      <s:iterator var="product_types" value="#session['PRODUCTTYPESTEMP']">
      <li>
      <label>
      <input type="checkbox" id="productTypeCodesTemp" name="productTypeCodesTemp" value="<s:property value="#product_types_temp.value"/>"
      <s:iterator var="productTypeTemp" value="#attr['productTypeCodesTemp']">
      <s:if test="%#attr['productType']==#product_types.value"> checked="checked" </s:if>
      </s:iterator>/>
      <span></span></label>
      <s:property value="#product_types.label"/>
      </li>
      </s:iterator>
      </ul>





      <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
      <ul class="nested">
      <li>
      <label><input type="checkbox" /><span></span></label>Warrants
      </li>
      <% colCntr=0; %>
      <s:iterator var="product_types" value="#session['PRODUCTTYPESTEMP']">
      <li>
      <label>
      <input type="checkbox" id="productTypeCodesTemp" name="productTypeCodesTemp" value="<s:property value="#product_types_temp.value"/>"
      <s:iterator var="productTypeTemp" value="#attr['productTypeCodesTemp']">
      <s:if test="%#attr['productType']==#product_types.value"> checked="checked" </s:if>
      </s:iterator>/>
      <span></span></label>
      <s:property value="#product_types.label"/>
      </li>
      </s:iterator>
      </ul>





      <li class="caret">
      <input type="checkbox" id="warrantsCb" checked="checked" /><label>
      <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
      <s:iterator value="#session['PRODUCTTYPESTEMP']">
      <s:property value="Baskets"/>
      <s:checkboxlist name="checkboxes" list="value"/>
      </s:iterator>
      </li>





      <li class="caret">
      <input type="checkbox" id="warrantsCb" checked="checked" /><label>
      <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
      <s:iterator value="#session['PRODUCTTYPESTEMP']">
      <s:property value="Baskets"/>
      <s:checkboxlist name="checkboxes" list="value"/>
      </s:iterator>
      </li>





      <td style="text-align:left;vertical-align:top;padding:0">
      <div class="acidjs-css3-treeview">
      <ul>
      <li class="caret">
      <input type="checkbox" id="warrantsCb" checked="checked" /><label>
      <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
      <s:checkboxlist name="checkboxes" list="#session['PRODUCTTYPESTEMP']['Baskets']"/>
      </li>
      </ul>
      </div>
      </td>





      <td style="text-align:left;vertical-align:top;padding:0">
      <div class="acidjs-css3-treeview">
      <ul>
      <li class="caret">
      <input type="checkbox" id="warrantsCb" checked="checked" /><label>
      <input type="checkbox" id="warrantsCb2"/><span></span></label><label for="warrantsCb" style="font-size:12px"><b>Warrants</b></label>
      <s:checkboxlist name="checkboxes" list="#session['PRODUCTTYPESTEMP']['Baskets']"/>
      </li>
      </ul>
      </div>
      </td>






      java jsp struts2






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 29 at 9:54







      I0I0II0

















      asked Mar 28 at 7:17









      I0I0II0I0I0II0

      1625 silver badges26 bronze badges




      1625 silver badges26 bronze badges

























          2 Answers
          2






          active

          oldest

          votes


















          1
















          I'm not entirely sure that i understand you but in struts 2 you can access session by implementing interface SessionAware in your action or getting it from ActionContext ActionContext.getContext().getSession(). There is no need to write java code directly into jsp



          To get data from session you can try this in your jsp:



          <s:iterator value="#session['PRODUCTTYPESTEMP']['Baskets']"> // iterates over list with map key Baskets
          <div>
          <s:property/> // gets element from Baskets
          </div>
          </s:iterator>


          EDIT:
          Try this, it gets list from map with key Baskets and creates checkboxes with values:
          <s:checkboxlist name="checkboxes" list="#session['PRODUCTTYPESTEMP']['Baskets']"/>






          share|improve this answer



























          • Hi Madis, I modified the 9th line like you mentioned , Now I get 3 check boxes but no values, the 3 count is correct because the basket key has 3 values.Still checking how to get the value. Thank you Madis, that was a great improvement.

            – I0I0II0
            Mar 28 at 10:28











          • I am completly lost here. Can you put the collection that you are trying to iterate over (for example Map<String, List<String>>) and what kind of data you want to display. I also dont understand what is product_types_temp, maybe this should be product_types. Also what is #attr that you are using.

            – Madis R
            Mar 28 at 10:39












          • Actually those are some existing code. I changed the product_types_temp to product_types still its showing null

            – I0I0II0
            Mar 28 at 12:05











          • I edited my original answer. Hope it helps

            – Madis R
            Mar 28 at 13:09











          • Will try this and let you know, Thank you

            – I0I0II0
            Mar 28 at 13:17


















          0
















          I am pasting the exact code, which is working for my requirement here,
          Hope this will help some poor souls out there.
          This is based on the solution provided by Madis R






          <ul class="nested">
          <s:iterator value="#session['PRODUCTTYPESTEMP']['Certificates']">
          <%--Certificates is the key we are passing into the map--%>
          <li>
          <label><input type="checkbox" /><span></span></label><s:property/>
          </li>
          </s:iterator>
          </ul>








          share|improve this answer

























          • If anyone can add any improvement ... pls do. Since this solution is purely based on trial and error.

            – I0I0II0
            Apr 1 at 12:40













          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392037%2ffetch-map-value-from-session-inside-struts-jsp%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1
















          I'm not entirely sure that i understand you but in struts 2 you can access session by implementing interface SessionAware in your action or getting it from ActionContext ActionContext.getContext().getSession(). There is no need to write java code directly into jsp



          To get data from session you can try this in your jsp:



          <s:iterator value="#session['PRODUCTTYPESTEMP']['Baskets']"> // iterates over list with map key Baskets
          <div>
          <s:property/> // gets element from Baskets
          </div>
          </s:iterator>


          EDIT:
          Try this, it gets list from map with key Baskets and creates checkboxes with values:
          <s:checkboxlist name="checkboxes" list="#session['PRODUCTTYPESTEMP']['Baskets']"/>






          share|improve this answer



























          • Hi Madis, I modified the 9th line like you mentioned , Now I get 3 check boxes but no values, the 3 count is correct because the basket key has 3 values.Still checking how to get the value. Thank you Madis, that was a great improvement.

            – I0I0II0
            Mar 28 at 10:28











          • I am completly lost here. Can you put the collection that you are trying to iterate over (for example Map<String, List<String>>) and what kind of data you want to display. I also dont understand what is product_types_temp, maybe this should be product_types. Also what is #attr that you are using.

            – Madis R
            Mar 28 at 10:39












          • Actually those are some existing code. I changed the product_types_temp to product_types still its showing null

            – I0I0II0
            Mar 28 at 12:05











          • I edited my original answer. Hope it helps

            – Madis R
            Mar 28 at 13:09











          • Will try this and let you know, Thank you

            – I0I0II0
            Mar 28 at 13:17















          1
















          I'm not entirely sure that i understand you but in struts 2 you can access session by implementing interface SessionAware in your action or getting it from ActionContext ActionContext.getContext().getSession(). There is no need to write java code directly into jsp



          To get data from session you can try this in your jsp:



          <s:iterator value="#session['PRODUCTTYPESTEMP']['Baskets']"> // iterates over list with map key Baskets
          <div>
          <s:property/> // gets element from Baskets
          </div>
          </s:iterator>


          EDIT:
          Try this, it gets list from map with key Baskets and creates checkboxes with values:
          <s:checkboxlist name="checkboxes" list="#session['PRODUCTTYPESTEMP']['Baskets']"/>






          share|improve this answer



























          • Hi Madis, I modified the 9th line like you mentioned , Now I get 3 check boxes but no values, the 3 count is correct because the basket key has 3 values.Still checking how to get the value. Thank you Madis, that was a great improvement.

            – I0I0II0
            Mar 28 at 10:28











          • I am completly lost here. Can you put the collection that you are trying to iterate over (for example Map<String, List<String>>) and what kind of data you want to display. I also dont understand what is product_types_temp, maybe this should be product_types. Also what is #attr that you are using.

            – Madis R
            Mar 28 at 10:39












          • Actually those are some existing code. I changed the product_types_temp to product_types still its showing null

            – I0I0II0
            Mar 28 at 12:05











          • I edited my original answer. Hope it helps

            – Madis R
            Mar 28 at 13:09











          • Will try this and let you know, Thank you

            – I0I0II0
            Mar 28 at 13:17













          1














          1










          1









          I'm not entirely sure that i understand you but in struts 2 you can access session by implementing interface SessionAware in your action or getting it from ActionContext ActionContext.getContext().getSession(). There is no need to write java code directly into jsp



          To get data from session you can try this in your jsp:



          <s:iterator value="#session['PRODUCTTYPESTEMP']['Baskets']"> // iterates over list with map key Baskets
          <div>
          <s:property/> // gets element from Baskets
          </div>
          </s:iterator>


          EDIT:
          Try this, it gets list from map with key Baskets and creates checkboxes with values:
          <s:checkboxlist name="checkboxes" list="#session['PRODUCTTYPESTEMP']['Baskets']"/>






          share|improve this answer















          I'm not entirely sure that i understand you but in struts 2 you can access session by implementing interface SessionAware in your action or getting it from ActionContext ActionContext.getContext().getSession(). There is no need to write java code directly into jsp



          To get data from session you can try this in your jsp:



          <s:iterator value="#session['PRODUCTTYPESTEMP']['Baskets']"> // iterates over list with map key Baskets
          <div>
          <s:property/> // gets element from Baskets
          </div>
          </s:iterator>


          EDIT:
          Try this, it gets list from map with key Baskets and creates checkboxes with values:
          <s:checkboxlist name="checkboxes" list="#session['PRODUCTTYPESTEMP']['Baskets']"/>







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 28 at 19:29

























          answered Mar 28 at 10:17









          Madis RMadis R

          1215 bronze badges




          1215 bronze badges















          • Hi Madis, I modified the 9th line like you mentioned , Now I get 3 check boxes but no values, the 3 count is correct because the basket key has 3 values.Still checking how to get the value. Thank you Madis, that was a great improvement.

            – I0I0II0
            Mar 28 at 10:28











          • I am completly lost here. Can you put the collection that you are trying to iterate over (for example Map<String, List<String>>) and what kind of data you want to display. I also dont understand what is product_types_temp, maybe this should be product_types. Also what is #attr that you are using.

            – Madis R
            Mar 28 at 10:39












          • Actually those are some existing code. I changed the product_types_temp to product_types still its showing null

            – I0I0II0
            Mar 28 at 12:05











          • I edited my original answer. Hope it helps

            – Madis R
            Mar 28 at 13:09











          • Will try this and let you know, Thank you

            – I0I0II0
            Mar 28 at 13:17

















          • Hi Madis, I modified the 9th line like you mentioned , Now I get 3 check boxes but no values, the 3 count is correct because the basket key has 3 values.Still checking how to get the value. Thank you Madis, that was a great improvement.

            – I0I0II0
            Mar 28 at 10:28











          • I am completly lost here. Can you put the collection that you are trying to iterate over (for example Map<String, List<String>>) and what kind of data you want to display. I also dont understand what is product_types_temp, maybe this should be product_types. Also what is #attr that you are using.

            – Madis R
            Mar 28 at 10:39












          • Actually those are some existing code. I changed the product_types_temp to product_types still its showing null

            – I0I0II0
            Mar 28 at 12:05











          • I edited my original answer. Hope it helps

            – Madis R
            Mar 28 at 13:09











          • Will try this and let you know, Thank you

            – I0I0II0
            Mar 28 at 13:17
















          Hi Madis, I modified the 9th line like you mentioned , Now I get 3 check boxes but no values, the 3 count is correct because the basket key has 3 values.Still checking how to get the value. Thank you Madis, that was a great improvement.

          – I0I0II0
          Mar 28 at 10:28





          Hi Madis, I modified the 9th line like you mentioned , Now I get 3 check boxes but no values, the 3 count is correct because the basket key has 3 values.Still checking how to get the value. Thank you Madis, that was a great improvement.

          – I0I0II0
          Mar 28 at 10:28













          I am completly lost here. Can you put the collection that you are trying to iterate over (for example Map<String, List<String>>) and what kind of data you want to display. I also dont understand what is product_types_temp, maybe this should be product_types. Also what is #attr that you are using.

          – Madis R
          Mar 28 at 10:39






          I am completly lost here. Can you put the collection that you are trying to iterate over (for example Map<String, List<String>>) and what kind of data you want to display. I also dont understand what is product_types_temp, maybe this should be product_types. Also what is #attr that you are using.

          – Madis R
          Mar 28 at 10:39














          Actually those are some existing code. I changed the product_types_temp to product_types still its showing null

          – I0I0II0
          Mar 28 at 12:05





          Actually those are some existing code. I changed the product_types_temp to product_types still its showing null

          – I0I0II0
          Mar 28 at 12:05













          I edited my original answer. Hope it helps

          – Madis R
          Mar 28 at 13:09





          I edited my original answer. Hope it helps

          – Madis R
          Mar 28 at 13:09













          Will try this and let you know, Thank you

          – I0I0II0
          Mar 28 at 13:17





          Will try this and let you know, Thank you

          – I0I0II0
          Mar 28 at 13:17













          0
















          I am pasting the exact code, which is working for my requirement here,
          Hope this will help some poor souls out there.
          This is based on the solution provided by Madis R






          <ul class="nested">
          <s:iterator value="#session['PRODUCTTYPESTEMP']['Certificates']">
          <%--Certificates is the key we are passing into the map--%>
          <li>
          <label><input type="checkbox" /><span></span></label><s:property/>
          </li>
          </s:iterator>
          </ul>








          share|improve this answer

























          • If anyone can add any improvement ... pls do. Since this solution is purely based on trial and error.

            – I0I0II0
            Apr 1 at 12:40















          0
















          I am pasting the exact code, which is working for my requirement here,
          Hope this will help some poor souls out there.
          This is based on the solution provided by Madis R






          <ul class="nested">
          <s:iterator value="#session['PRODUCTTYPESTEMP']['Certificates']">
          <%--Certificates is the key we are passing into the map--%>
          <li>
          <label><input type="checkbox" /><span></span></label><s:property/>
          </li>
          </s:iterator>
          </ul>








          share|improve this answer

























          • If anyone can add any improvement ... pls do. Since this solution is purely based on trial and error.

            – I0I0II0
            Apr 1 at 12:40













          0














          0










          0









          I am pasting the exact code, which is working for my requirement here,
          Hope this will help some poor souls out there.
          This is based on the solution provided by Madis R






          <ul class="nested">
          <s:iterator value="#session['PRODUCTTYPESTEMP']['Certificates']">
          <%--Certificates is the key we are passing into the map--%>
          <li>
          <label><input type="checkbox" /><span></span></label><s:property/>
          </li>
          </s:iterator>
          </ul>








          share|improve this answer













          I am pasting the exact code, which is working for my requirement here,
          Hope this will help some poor souls out there.
          This is based on the solution provided by Madis R






          <ul class="nested">
          <s:iterator value="#session['PRODUCTTYPESTEMP']['Certificates']">
          <%--Certificates is the key we are passing into the map--%>
          <li>
          <label><input type="checkbox" /><span></span></label><s:property/>
          </li>
          </s:iterator>
          </ul>








          <ul class="nested">
          <s:iterator value="#session['PRODUCTTYPESTEMP']['Certificates']">
          <%--Certificates is the key we are passing into the map--%>
          <li>
          <label><input type="checkbox" /><span></span></label><s:property/>
          </li>
          </s:iterator>
          </ul>





          <ul class="nested">
          <s:iterator value="#session['PRODUCTTYPESTEMP']['Certificates']">
          <%--Certificates is the key we are passing into the map--%>
          <li>
          <label><input type="checkbox" /><span></span></label><s:property/>
          </li>
          </s:iterator>
          </ul>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 1 at 12:27









          I0I0II0I0I0II0

          1625 silver badges26 bronze badges




          1625 silver badges26 bronze badges















          • If anyone can add any improvement ... pls do. Since this solution is purely based on trial and error.

            – I0I0II0
            Apr 1 at 12:40

















          • If anyone can add any improvement ... pls do. Since this solution is purely based on trial and error.

            – I0I0II0
            Apr 1 at 12:40
















          If anyone can add any improvement ... pls do. Since this solution is purely based on trial and error.

          – I0I0II0
          Apr 1 at 12:40





          If anyone can add any improvement ... pls do. Since this solution is purely based on trial and error.

          – I0I0II0
          Apr 1 at 12:40


















          draft saved

          draft discarded















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55392037%2ffetch-map-value-from-session-inside-struts-jsp%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해