• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to specify an object in application scope

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic