how to display key, value which is stored in session object in a JSP using struts

Posted on 2004-04-15
Last Modified: 2011-09-20

  I am passing key, value pair with session object.
I wanted to display this value in my JSP using struts.
Which tag of struts i suppose to use.

I appreciate ur help!

Question by:mvkraju
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Accepted Solution

searlas earned 20 total points
ID: 10832684

Let's suppose your key value is an instance of Map.Entry...

Presumably, somewhere you have:
session.setAttribute("mypair", mapEntry);

Then, in your JSP
<bean:write name="mypair" property="value" scope="session"/>

(scope="session" is optional...)

Author Comment

ID: 10832764
here you assigning key to the name attribute. How about property?
What are we assigning it for?

Expert Comment

ID: 10832829
You have your name/values in an object,  I'm using the class Map.Entry as an example, this has two relevant methods, getKey() which returns the key, and getValue() returning the value.

name - the name the name-value-pair object is stored as under the session
property - the method to call on the name-value-pair object to retrieve the value (minus 'get', and always start lower case)

<bean:write name="mypair" property="value" scope="session"/>

Is effectively the same as saying:
out.write( ((Map.Entry) session.getAttribute("mypair")).getValue() );


Author Comment

ID: 10832892
It's working fine.
if worked with out property attribute also
<bean:write name="mypair" scope="session"/>

Thanks for ur explanation.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft is moving in-place eDiscovery & hold from ECP to EOP console under Content Search in Search and Investigation Options.  In this post, I will be showing you how to export emails to a PST file using the Content Search Options.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question