• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference between session, application, request scopes

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65217
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 231
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

" 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic