Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

transferring ResultSet from EJB to JSP/Java Class

 
benjamas chote
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic