• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

including jsp in servlet

 
Greenhorn
Posts: 1
  • 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 ]
 
Ranch Hand
Posts: 129
  • 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.
 
Ranch Hand
Posts: 259
  • 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 ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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.
 
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!