• 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

About servlet

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got a question about servlet. Can anyone tell me if i can pass an object from a servelt to jsp.
My intention is:
1. use a method from EJB in servlet and get a 'Collection' of object.
2. pass this object to jsp file for displaying.
thanks
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IMO, there shouldn't be any problem in passing servlet's object to jsp.
Give it a try
Good luck
Rashid Ali
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use include or forward method of RequestDispatcher to forward the control to jsp. Use setAttribute method of request obj to pass the collection obj which u get from EJB ...
-----------------

Originally posted by ordin sword:
I got a question about servlet. Can anyone tell me if i can pass an object from a servelt to jsp.
My intention is:
1. use a method from EJB in servlet and get a 'Collection' of object.
2. pass this object to jsp file for displaying.
thanks

 
fei long
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for replying.
Could you give me a sample code or just a piece of code to do it.
 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ordin, u can use the request object
In the Servlet,
req.setAttribute("name", Object);
and in the jsp
Object x = request.getAttribute("name");
but i would not recommend that coz u have no control over the size of your Collection. I don't know what u are querying the DB for in the bean but if there are something more than 10-20 K elements in the collection, then please use a serializable custom class that u populate in the servlet and access in the jsp. I guess that would be a more robust and scalable solution.
HTH
Sahil
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic