John Brecht wrote:
> 
> I would like to be able to pass a list of parameters of arbitrary size to a
> servlet.  The syntax for passing parameters via a properties file is:
> 
> Syntax: servlet.[classname].initArgs=[name]=[value],[name]=[value],...
> 
> This syntax requires you to have a different name for each parameter, so it
> can't be of arbitrary size.  So what I need to do is have a safe delimiter
> character, for instance "&", that my servlet can use to parse a single
> string parameter into the list of parameters it represents.  Is the
> ampersand (&) a safe choice as far as JServ is concerned?  Is there a better
> choice?
> 
> (My specific situation is that I would like to have my servlet be able to
> instantiate Classes given Strings passed to them by a client applet.  This
> will be done using the URLClassLoader, which in turn needs a classpath to
> hunt for classes within.  It would be nice to pass this classpath, which may
> consist of more than one URL, via the servlet parameters.  That way, if I'm
> just changing the directory structure of my server a bit I don't have to
> recompile a bunch of applets and servlets.  Instead, I just make the changes
> in the appropriate properties file.)

What I have done in this situation (and I stole the idea from the GSP
guys) is to supply my servlet with a "propfile" parameter as you
describe:

servlet.[classname].initArgs=propfile=/path/to/propfile.dat

which is the path to a file containing all the parameters I use for my
apps (jdbc urls, usernames, passwords etc...) and wrote a java class
(ConfigurationFileParser) to parse the file and store the parameters.
The propfile is then shared with another (non-JServ) java application
that users the same ConfigurationFileParser class. Any changes need to
be made once only, 'touch' the zone.properties file and the servlet is
reloaded at the next request, re-parsing my configurations file and
loading the new parameters...

Damian

-- 
Damian Fauth                                       201 Sussex Street
Software Engineer                                   Sydney, NSW 2000
John Fairfax Holdings Ltd                                  Australia
[EMAIL PROTECTED]                    Ph. (+612) 9282 3528


----------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to