Ryan,
>> Not really. If the question is "how do I retrieve the stuff I put in
>> servletcontext?", the answer is getServletContext().getAttribute(
>> attributeName ).
>
> Thanks a lot, David.
Yeah, sorry. I misunderstood the question the first time :(
So, your only option is to use ServletConte
Thanks a lot, David.
Ryan
Christopher Schultz wrote:
Not really. If the question is "how do I retrieve the stuff I put
in servletcontext?", the answer is getServletContext().getAttribute
( attributeName ).
Then just cast the result to the type it's supposed to be (String,
Array, Hashtabl
Christopher Schultz wrote:
Ryan,
One more question: What is the best method for retrieving the values?
You only have one option: ServletContext.getInitParameter
There are, however, some tools that can help you load data that is not
String-based. Jakarta commons beanutils package (s
Where are you getting the parameter from? Is it going to change a lot?
I store parameters in the server.xml in the
section as entries, and then retrieve them with a call to
this routine:
public static String getEnvironmentVariable( String envVarName,
String varDefault) {
String
Ryan,
> One more question: What is the best method for retrieving the values?
You only have one option: ServletContext.getInitParameter
There are, however, some tools that can help you load data that is not
String-based. Jakarta commons beanutils package (specifically the
'converters' portion)
One more question: What is the best method for retrieving the
values? Thanks again.
-Ryan
On Jul 31, 2006, at 2:47 PM, David Smith wrote:
ServletContextListener is a new feature of servlet spec 2.4 (tomcat
5.0.x, 5.5.x). The essential parts are:
1. write a class implementing the
java
You are creating a ServletContextListener, which must be configured in
the "listeners" section of your web.xml file: simply mention the
ServletContextListener in there, and the contextInitialized() method
will be called when the webapp is initialized (i.e. once for the
life of
the webapp).
If
David,
> ServletContextListener is a new feature of servlet spec 2.4 (tomcat
> 5.0.x, 5.5.x).
Correction: this is available in servlet spec 2.3 (Tomcat 4.x).
-chris
signature.asc
Description: OpenPGP digital signature
Ryan,
> Where would this code go that gets and sets the value, so that it
> would only run once collectively for all users (not once per user)?
It's right here:
>> The usual way of doing this is to create a ServletContextListener
>> which implements the init() method, grabs the values from the
>
ServletContextListener is a new feature of servlet spec 2.4 (tomcat
5.0.x, 5.5.x). The essential parts are:
1. write a class implementing the javax.servlet.ServletContextListener
interface. The interface itself requires two methods --
contextInitialized() [see below] and contextDestroyed().
You're looking for . You can add these parameters to any
filter or servlet, or at the top-level for the entire webapp, and get
them when the filter or servlet runs (or any time you can get an
instance of the ServletContext which represents the webapp).
The usual way of doing this is to create a Se
Ryan,
> Is there a way to initialize an array (or any other Java object, for
> that matter), so that it is available to all users? I would like to
> execute some Java methods to precompute and store two arrays to avoid
> creating them every visit for every user. I read something about
> param-na
12 matches
Mail list logo