On Fri, 4 Jan 2002, Anthony Tagunov wrote:

> Hello Milt!
>
> ME> Another possibility is to define the param (in web.xml) as a
> ME> comma-separated value (csv) and parse it when you get it.  For
> ME> example:
>
> ME>   <init-param>
> ME>     <param-name>team</param-name>
> ME>     <param-value>GoodGuys,Enemy</param-value>
> ME>   </init-param>
>
> ME> Then:
>
> ME>   ...
> ME>   String teamNameCSV = config.getInitParameter("appName");
> ME>   String[] teamNames = StringUtils.splitCSV(teamNameCSV);
> ME>   ...

Whoops, just noticed a problem with this pseduo-code, the parameter
name in the first line is wrong, it should be:

  String teamNameCSV = config.getInitParameter("team");

I copied and pasted it from elsewhere in the post I was responding to,
either it was incorrect there too, or it was in a different context.
Still, my bad, I should've noticed it then.


> ME> (StringUtils is my own class; it contains mostly static functions,
> ME> including ones to do this parsing.)
> A common approach is to use java.util.StringTokenizer for this
> purpose.

Sounds like you've done something similar :-).  In fact, my code does
use that class too.  (Actually, a roll-my-own, slightly modified
version of it, since there was some behavior of it that was
problematic for the way I needed it to work -- I think it had to do
with when there were two delimiter characters in a row --
e.g. "GoodGuys,,Enemy" -- I wanted it to return an empty string, but
instead it swallowed up all the delimiters.  This is fairly old code,
so perhaps that's not right or it's changed.)


> ME> Note: I haven't actually tried this, I assume there are no gotchas,
> ME> like that commas aren't allowed in param values.
> No gotchas, take my word :-)

Thanks for verifying that.

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to