aspose file tools*
The moose likes Servlets and the fly likes session value from jsp -> Servlet / Servlet -> jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "session value from jsp -> Servlet / Servlet -> jsp" Watch "session value from jsp -> Servlet / Servlet -> jsp" New topic
Author

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

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1372
Ho can i pass session value form jsp to Servlet and Servlet to jsp ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60996
    
  65

Please take the time to post in appropriate forums. This has been moved to the Servlets forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60996
    
  65

You don't. The session is available from all participating JSPs and servlets so no passing of anything is necessary.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
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?
Jinglong Wang
Greenhorn

Joined: Mar 05, 2010
Posts: 12
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

Joined: Apr 01, 2009
Posts: 643
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

Joined: Mar 05, 2010
Posts: 12
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..
Ravishanker kumar
Ranch Hand

Joined: Jul 20, 2006
Posts: 53
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session value from jsp -> Servlet / Servlet -> jsp