aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes transferring ResultSet from EJB to JSP/Java Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "transferring ResultSet from EJB to JSP/Java Class" Watch "transferring ResultSet from EJB to JSP/Java Class" New topic
Author

transferring ResultSet from EJB to JSP/Java Class

benjamas chote
Greenhorn

Joined: Aug 28, 2001
Posts: 1
As ResultSet isn't serializable object,I cannot pass it into Client.
I ever hear about javax.sql.RowSet.How shall I use it?
Please tell me about implementing and using javax.sql.RowSet or if you have the other method for passing this ResultSet,tell me too.
Besides,I don't know about structure of queried information. Consequently I cannot use Array or Collection.
Thanks,Ben
Mahesh Kulkarni
Ranch Hand

Joined: Jul 05, 2001
Posts: 62
Hi benjamas ,
Resultset can be sent to a jsp through session.I hope you are retrieving the data from the data base in a servlet.Put that retrieved resultset in session as follows.
String sql="select * from tablename";
Statement stmt=null;
Connection con=null;
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
HttpSession session=request.getSession(true);
session.setAttribute("rs",rs);
Now in your jsp get the value of this by following code
<%session = request.getSession (true) ;<br /> rs=(ResultSet)session.getAttribute("rs");<br /> %>
Display this in tabular format as follows
<%while (rs.next())<br /> {<br /> %>
<tr><td><tr>
table goes here
<%<br /> }<br /> %>
I hope this will solve your problem.
Thanx,
Mahesh
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: transferring ResultSet from EJB to JSP/Java Class