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 How to specify an object in application scope Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to specify an object in application scope" Watch "How to specify an object in application scope" New topic
Author

How to specify an object in application scope

Venkatesh Rajendran
Ranch Hand

Joined: May 17, 2001
Posts: 59
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

Joined: Jul 18, 2001
Posts: 2712
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to specify an object in application scope
 
Similar Threads
jsp:useBean type requirements
jsp:useBean scope question
Is jsp:useBean scope='session' attribute is going to be deprecated?
Question about page scope and implicit object
Storing InputStream object to Application scope in servlet and retrieving