wood burning stoves
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
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

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
Tripp Bishop

Joined: Aug 23, 2002
Posts: 21

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.


I agree. Here's the link: http://aspose.com/file-tools
subject: Sending a bean to a struts jsp page
It's not a secret anymore!