• 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

session value from jsp -> Servlet / Servlet -> jsp

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ho can i pass session value form jsp to Servlet and Servlet to jsp ?
 
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
Please take the time to post in appropriate forums. This has been moved to the Servlets forum.
 
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
You don't. The session is available from all participating JSPs and servlets so no passing of anything is necessary.
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

kri shan wrote:Ho can i pass session value form jsp to Servlet and Servlet to jsp ?



In the Servlet code, you can get the session object, and then call setAttribute on it.
In the JSP code, you can use the JSTL tag to do this.

Is this what you mean?
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think you use the "request" best.



but, session object is same to request in principle.

be care for to use the session
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jinglong Wang wrote:i think you use the "request" best.



but, session object is same to request in principle.

be care for to use the session


Well, they're the same in that they both scoped environments. However, the session and request are two separate scopes with completely separate life cycles.
 
Jinglong Wang
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark E Hansen wrote:

Jinglong Wang wrote:i think you use the "request" best.



but, session object is same to request in principle.

be care for to use the session


Well, they're the same in that they both scoped environments. However, the session and request are two separate scopes with completely separate life cycles.



yeah, the session greater than request.
request may be use in one request, but session may be use many request and response.
they differents is SCOPE so that life cycles is differents.
Session object care for the JVM ram in use.

my english is not good
excuse me..
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
request or session can be used for different purpose.
If you want to pass some value from servlet to jsp and you are using those value on only that forwarded jsp file, I think request is the best approach and if you want to use passed value on any multiple jsp file then session can be used.

If you want to pass some value from jsp file to servlet, in this case either request parameter or session can be used.
In any case if you are using session, same session will be available in jsp or servlet if you are getting session as
,
you don't need to do anything extra to pass the session. But if you using , be careful, it may return new session.
reply
    Bookmark Topic Watch Topic
  • New Topic