Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending a bean to a struts jsp page

 
david allen
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic