• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to specify an object in application scope

 
Venkatesh Rajendran
Ranch Hand
Posts: 59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

How can I specify an object in application scope, for example I have specified in JSP as follows, similarly I have an object I want to specify it in Servlets.

<jsp:useBean class="mypack.MyClass" id="MyClassObj" scope="application"/>

Thanks in advance.

Venkat
 
Chris Mathews
Ranch Hand
Posts: 2712
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All that application scope means in a JSP is that the object is going to be set in the ServletContext. Therefore, to do the same thing in a Servlet you would do:


Word of warning, due to the nature of Servlets and Web Applications, the ServletContext is not thread-safe. Be very careful in how you use it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic