• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

passing info from servlet to jsp

 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm learning
i have a servlet that deals with database and gets a recordSet; i've an util class that prepares data from that recordset to be presented and now i want to pass this string (all the prepared data from util class) that i have in my servlet to a jsp (presentation); the examples i saw used something along this:

my question is: is the standard way to use httpsession to tranfer data from servlet to jsp? or instead tranfer the util class directly and have the jsp deal with it? or any other way?

TiA
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by miguel lisboa:
my question is: is the standard way to use httpsession to tranfer data from servlet to jsp?



No, the request scope is much more commonly used. The session would only be used for data that needs to persist over the course of the session rather than merely from the servlet to the JSP for this request.

or instead tranfer the util class directly and have the jsp deal with it?



I have no idea what you mean by this.
[ November 18, 2006: Message edited by: Bear Bibeault ]
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have no idea what you mean by this.


i refer to this post from Stan James (here)
request.setAttribute("name", someObjectTheJSPNeedsToUse);getServletContext().getRequestDispatcher(jspName).forward(request, response);

The session would only be used for data that needs to persist over the course of the session rather than merely from the servlet to the JSP for this request.

i'm sorry but i dont quite get what you mean: are you saying that, for example, for dysplaying the contents for a very simple blog page my solution would be ok?
[ November 18, 2006: Message edited by: miguel lisboa ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stan's example correctly uses request scope to "pass" the data from servlet to JSP.
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic