This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes Sending a bean to a struts jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Sending a bean to a struts jsp page" Watch "Sending a bean to a struts jsp page" New topic
Author

Sending a bean to a struts jsp page

david allen
Ranch Hand

Joined: Sep 27, 2002
Posts: 185
Hi all,

thanks for your help regarding previous post. I have one more question.

I have populated a bean and I wish to send it to a jsp page to be displayed.

How and where do I place the object. Do I put the bean in the response object of the action class then 'forward' the user to the jsp page so it can be displayed?

What is the best way to do this.

Note: I dont want to reuse the data so I cant see any point placing it in the session.

thank you
david
Tripp Bishop
Greenhorn

Joined: Aug 23, 2002
Posts: 21
David,

put your bean into the request object like so:

Object mybean = someobject;

request.setAttribute("mybean", mybean);

Then, on the JSP you can access the bean like so:

<bean efine id="thebean" name="mybean" scope="request" />

Make sure that you've included the struts bean tld in the JSP. Look in the struts docs for more info about the bean tags.

Cheers,

Tripp
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Sending a bean to a struts jsp page
 
Similar Threads
Beans in servlets?
Problem when the struts validator rejects user input
JSP /Servlet - Printing issue
Beans (again)
Maintaining sessions