?
Solved

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

Posted on 2004-04-15
4
Medium Priority
?
346 Views
Last Modified: 2011-09-20
HI,

  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!

Thanks
0
Comment
Question by:mvkraju
[X]
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
4 Comments
 
LVL 7

Accepted Solution

by:
searlas earned 80 total points
ID: 10832684
bean:write

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...)
http://jakarta.apache.org/struts/userGuide/struts-bean.html#write
0
 

Author Comment

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

Expert Comment

by:searlas
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)

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

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


0
 

Author Comment

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

Thanks for ur explanation.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
What's worse than having your data encrypted by ransomware? Getting attacked by a so-called "wiper," which simply destroys the data and offers you no hope of ever seeing it again.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

770 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