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

including jsp in servlet

 
ajinder singh
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i am a beginner. i am using servlets and jsp to fetch the records from database. once a query is made to database (in servlets), the records are fetched. i want to show these records on jsp file. i want to store the resultset in a variable, then include the jsp page using "reqestDispatcher" and on that jsp page, make a loop and show the records.
i know that we can store the variable as request variable or session variable. but i dont want to store the variable in them. i just want to make a variable, and use it in jsp using a loop. is this possible?
kindly help.

thanks in advance,
Ajinder

[ May 18, 2008: Message edited by: ajinder singh ]
[ May 19, 2008: Message edited by: ajinder singh ]
 
Ashok Kumar Babu
Ranch Hand
Posts: 129
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i know that we can store the variable as request variable or session variable. but i dont want to store the variable in them. i just want to make a variable, and use it in jsp using a loop. is this possible?


Please elaborate your question.
 
karthikeyan Chockalingam
Ranch Hand
Posts: 259
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can store the result in a cache with a specific key (identifier) [using Java Collection] and in your JSP you can retrieve the result from the cache [using the same key used to store the result]. This approach is useful only if the result fetched can be reused across requests [or sessions].
[ May 19, 2008: Message edited by: karthi keyan ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's better to:

1) Not store resultSets any longer than necessary.
Grab what you need from them and release them.

2) Forward to your JSP (rather than include it).
If you follow the advice in #1, you should be able to close all of your database objects before forwarding so there will be no need to do an include.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic