This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Diffenrence between application and servletConfig - servletcontext

 
Fouad Fares
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65220
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Fouad Fares
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic