I do this frequently, and if you are doing anything similar, this is the best
way.
Request the value from the returning form [String string =
req.getParameter(varName);]
Then do a substring for the first 3 characters [string =
string.subString(offset, endset)].
If you are positive that the first 3 charicters are all you are looking at and
there is a fixed number of choices then String has a method startsWith(String
prefix) that can do some comparisons.

Write back if you have any questions.
DanC

Bruno Lowagie wrote:

> > basically I have a form with several fields and I am
> > trying to validate some of the fields.
> > eg I am getting  a value as
> > String c1plnt = req.getParameterValues("C1PLNT")[0];
> > basically I just need the first three characters of
> > the parameter.
> > Any suggestion?
> > Thanks,
> > J
>
> c1plnt.substring(0, 3)
> (throws an IndexOutOfBoundsException if the length of c1plnt < 3)
> --
> -------------------------------------------------------------------
> Bruno Lowagie           Academisch Rekencentrum Universiteit Gent
> Tel : 09/264.48.14      e-mail : [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

___________________________________________________________________________
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