• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sending a bean to a struts jsp page

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic