File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

requestDispatcher

 
lathainses muthu
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
result set should be transfered from servlet to jsp
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by lathainses muthu:
result set should be transfered from servlet to jsp


can you explain in detail?

note:

---------------------------
please give meaningful subjectline
-------------------------------
 
Schandha Ravi
Ranch Hand
Posts: 167
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If at all you are looking for making the resultset available to the called JSP, I would put the resultset into a session and call the jsp. You can also put the resultset into a request, call the jsp and can achieve the same results. By putting in session, I make sure that those values are available across all requests with in the session.
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi lathainses muthu
See How to ask questions on Javaranch

It will help you.
 
Ankit Garg
Sheriff
Posts: 9495
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey don't store a ResultSet into a session. A ResultSet is connected to the database on which the query was run. If you store a ResultSet then strange things might happen. The connection to the database might remain open. But I think it will not allow you to add a ResultSet object to a session (I once tried to return a ResultSet from a RMI server and it didn't work).

Instead use javax.sql.rowset.CachedRowSet i.e. store it in the session as it follows disconnected architecture.
For details refer to the JDK Documentation.
 
Michael Ku
Ranch Hand
Posts: 510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSPs are just for presentation not logic. You should process the ResultSet in the Servlet and transform the results into a presentation view which you place into the session.
 
Schandha Ravi
Ranch Hand
Posts: 167
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankit,

Can you explain how you were not able to add a Resultset to session and what was the problem you encountered.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As peviously pointed out, resultsets in the session is a bad bad idea. Copy the data to a suitable collection and store that.
 
Ankit Garg
Sheriff
Posts: 9495
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Schandha Ravi:
Hi Ankit,

Can you explain how you were not able to add a Resultset to session and what was the problem you encountered.


Well I didn't store the ResultSet in a session. I actually returned a ResultSet from a RMI method. But it gave me some error at run time(I don't remember what). I think it's because ResultSet is not Serializable. Now I think that if that's true then CachedRowSet will not work either as it is also not Serializable. Bear Bibeault is right, you should use some Collection or Map implementation...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Ankit G@rg", please check your private messages for an important administrative matter.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic