This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About servlet

 
fei long
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Rashid Ali
Ranch Hand
Posts: 349
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying.
Could you give me a sample code or just a piece of code to do it.
 
sandy gupta
Ranch Hand
Posts: 228
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic