aspose file tools*
The moose likes Servlets and the fly likes About servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "About servlet" Watch "About servlet" New topic
Author

About servlet

fei long
Ranch Hand

Joined: Apr 04, 2002
Posts: 48
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

Joined: Jan 16, 2001
Posts: 349
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

Joined: Feb 27, 2002
Posts: 8919

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


Groovy
fei long
Ranch Hand

Joined: Apr 04, 2002
Posts: 48
Thanks for replying.
Could you give me a sample code or just a piece of code to do it.
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
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


Adios
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: About servlet