Re: Initializing Parameter

2006-07-31 Thread Christopher Schultz
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

Re: Initializing Parameter

2006-07-31 Thread Ryan O'Hara
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

Re: Initializing Parameter

2006-07-31 Thread David Smith
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

Re: Initializing Parameter

2006-07-31 Thread David Kerber
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

Re: Initializing Parameter

2006-07-31 Thread Christopher Schultz
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)

Re: Initializing Parameter

2006-07-31 Thread Ryan O'Hara
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

Re: Initializing Parameter

2006-07-31 Thread Ryan O'Hara
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

Re: Initializing Parameter

2006-07-31 Thread Christopher Schultz
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

Re: Initializing Parameter

2006-07-31 Thread Christopher Schultz
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 >

Re: Initializing Parameter

2006-07-31 Thread David Smith
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().

Re: Initializing Parameter

2006-07-31 Thread Ryan O'Hara
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

Re: Initializing Parameter

2006-07-31 Thread Christopher Schultz
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