Solved

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

Posted on 2004-04-15
4
329 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
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
searlas earned 20 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

There are many Password Managers (PM) out there to choose from. PM's can help with your password habits and routines, but they should not be a crutch you rely on too heavily. I also have an article for company/enterprise PM's.
Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now