File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes difference between session, application, request scopes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "difference between session, application, request scopes" Watch "difference between session, application, request scopes" New topic
Author

difference between session, application, request scopes

Padma priya Gururajan
Ranch Hand

Joined: Oct 05, 2006
Posts: 437
Hi,

What are the different areas to use session, application and request scopes? Session and application seem to be the same. What are the difference?

Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Please take the time to choose an appropriate forum for your posts. This forum is for questions on general Java. For more information, please click this link ⇒ CarefullyChooseOneForum.

This post has been moved to a more appropriate forum.


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

Joined: Jan 10, 2002
Posts: 61766
    
  67

Padma priya Gururajan wrote:Session and application seem to be the same.

They are not. Scoped variables placed in session scope are available only to the current session. Scoped variables placed in application scope are shared across the entire application.
shivam singhal
Ranch Hand

Joined: Jul 15, 2012
Posts: 226

SESSION SCOPE ::Sessions are use to recognise the client. Session scope are NOT THREAD SAFE and use during communication with the particular client..
APPLICATION SCOPE :: once you set anything on application scope, ANY servlet in your web-app can get it ,, (that is application scope is available for full web-app )
REQUEST SCOPE :: things which you set is request scope can only be accessed by the page on which the request have been sent..
shivam singhal
Ranch Hand

Joined: Jul 15, 2012
Posts: 226


" ANY servlet in your web-app can get it "

servlets can get it using getServletContext.getInitParameter("name");

getServletContext in SERVLETS is equivalent to application in JSP
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: difference between session, application, request scopes