hello experts,
I have one question regarding Application variables in jsp.
How to use application variables. What is its scope.What r its advantages.
thanx in advance
vinod
-
JSP (3 messages)
- Posted by: vinod c
- Posted on: January 27 2001 00:39 EST
Threaded Messages (3)
- JSP by Uri Cohen on January 28 2001 18:10 EST
- JSP by vinod c on January 29 2001 23:52 EST
- Hi i am dinesh by dinesh sood on June 16 2008 11:16 EDT
- JSP by vinod c on January 29 2001 23:52 EST
-
JSP[ Go to top ]
- Posted by: Uri Cohen
- Posted on: January 28 2001 18:10 EST
- in response to vinod c
Application variables are simply Java objects, which are identified by their unique name (Just like session variables). Their scope is the entire web application, meaning once you have set then in the application, they will stay there until you remove them (or until the application teminates). An application, as defined by Sun, is "a collection of servlets and content installed under a specific subset of the server's URL namespace such as /catalog and possibly installed via a .war file".
They are usefull for global variables that all your jsp's and servlets have to access, and are typically initialized when the application starts.
An example for this might be a class which contains some application constants, which are read from a data source upon start up, and have to be accessed by servlets and jsp's. You use them like this:
in jsp's: application.setAttribute("variableName", someObject)
in servlets: getServletContext().setAttribute("variableName", someObject)
-
JSP[ Go to top ]
- Posted by: vinod c
- Posted on: January 29 2001 23:52 EST
- in response to Uri Cohen
hello
can u send me some more information on this.
vinod -
Hi i am dinesh[ Go to top ]
- Posted by: dinesh sood
- Posted on: June 16 2008 11:16 EDT
- in response to vinod c
well my question is How can we get the value in Servlet, which is set in jsp by using "application.setAttribute("anyvalue",anyvalue);"? i dont want any other alternative request.setAttribute object or use session.setAttribute in jsp instead of apllication.setAttribute.... I jst need a specific answer related to my question only.... thx