Hi,
Can you suggest a wayout of how I can declare a Global variable in JSP which can be accessed by various methods, like we do in init() method of Servlets ?
thanx,
dipes.
dipes.biswas@wipro.com
-
Declaring Global Variable in JSP (5 messages)
- Posted by: Dipes Biswas
- Posted on: December 11 2000 01:34 EST
Threaded Messages (5)
- Declaring Global Variable in JSP by amol anvekar on December 11 2000 05:40 EST
- Declaring Global Variable in JSP by Chris Siemback on December 13 2000 15:35 EST
- Declaring Global Variable in JSP by Z Huang on December 17 2000 14:01 EST
- Declaring Global Variable in JSP by Z Huang on December 17 2000 14:04 EST
- Declaring Global Variable in JSP by Rahul Rele on January 18 2001 08:26 EST
- Declaring Global Variable in JSP by Z Huang on December 17 2000 14:04 EST
-
Declaring Global Variable in JSP[ Go to top ]
- Posted by: amol anvekar
- Posted on: December 11 2000 05:40 EST
- in response to Dipes Biswas
i dont know which specification of jsp u r using but in jsp 1.1 spec there is a method called jspinit() which i think may be useful for u. -
Declaring Global Variable in JSP[ Go to top ]
- Posted by: Chris Siemback
- Posted on: December 13 2000 15:35 EST
- in response to Dipes Biswas
You can place objects in the application object. All JSPs have access to this scope, so it would indeed be global. -
Declaring Global Variable in JSP[ Go to top ]
- Posted by: Z Huang
- Posted on: December 17 2000 14:01 EST
- in response to Dipes Biswas
I understand what you are trying to do. But Java doesn't have the concept of global variable. Instead you can declare class members or instance members, either they are member methods or variables.
To do this in JSP, you just need to use the declarative tag
<% [varviable or function declaration] %>
for example:
<% private int id; %> declares a private integer named id;
<% public static int id; %> declares a public integer id with class scope.
You can also put methods inside the tag. -
Declaring Global Variable in JSP[ Go to top ]
- Posted by: Z Huang
- Posted on: December 17 2000 14:04 EST
- in response to Z Huang
OOPS, I meant <%! ... %> rather than <% ... %>. Sorry that my finger moved too fast.
<%! [varviable or method declaration] %>
for example:
<%! private int id; %><%! public static int id; %>
-
Declaring Global Variable in JSP[ Go to top ]
- Posted by: Rahul Rele
- Posted on: January 18 2001 08:26 EST
- in response to Z Huang
u can write a bean and store ur global variable there...