aspose file tools*
The moose likes JSP and the fly likes Diffenrence between application and servletConfig - servletcontext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Diffenrence between application and servletConfig - servletcontext" Watch "Diffenrence between application and servletConfig - servletcontext" New topic
Author

Diffenrence between application and servletConfig - servletcontext

Fouad Fares
Ranch Hand

Joined: Apr 16, 2003
Posts: 38
Hello,
I want to clarify the difference between using application objects [getattribute - setattribute] and the servletconfig - servletcontext objects.
Please note that in my web application i create an init class called from the web.xml this class implement the servletcontextListener like the following code :
=======================
public class Jcls_Init implements ServletContextListener
{
public void contextInitialized(ServletContextEvent sce)
{
sce.getServletContext().setAttribute("config","1");
}
}
------------------------
And to retrive this value in my jsp page i write the following code :
String s_val = (String)getServletConfig().getServletContext().getAttribute("config") ;
=========================
Questions :
1- Is this king of coding are storing the value
of config variable in the memory once we start the application
through the Oracle Entreprise manager ?
2- Is the value of config variable persist as long as the application [oc4j]
is up and running .
3- What is the difference between the above code and the application.getAttribute and application.setattribute.
Best Regards.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

The "application" variable exposed in JSP pages stores its variable in the servlet context. For the purposes of scope variables, they are one and the same.
Once set into application context, the variable will remain there until explicitly removed or the application itself is removed.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Fouad Fares
Ranch Hand

Joined: Apr 16, 2003
Posts: 38
Hello,
As i understand that the application and servletcontext are the same.
and the variable of type application are initialised once starting the web application through the Oracle entreprise manager and it will be remove from memory once stopping the web application .
Best regards,
Fouad
 
wood burning stoves
 
subject: Diffenrence between application and servletConfig - servletcontext
 
Similar Threads
Servlet concepts doubts
Object through out application
Configure Portlet request attributes for Weblogic 10.2
My example with ServletContextListener and ServletContextAttrib.
application scope in servlet