GeeCON Prague 2014*
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
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
 
GeeCON Prague 2014
 
subject: Sending a bean to a struts jsp page