> > I use constructs like this:
> >
> >    int position;
> >    try {
> >       position = new
> > Integer( request.getParameterValues("Position") ).intValue();
> >    } catch( MalformedNumberException mne ) {
> >       // Set value required if non-numeric value was entered
> >       position = -1;
> >    }

Paul Holser wrote:
>
> jason hunter, author of "Java Servlet Programming"
> (O'Reilly tea kettle book), offers a nice servlet
> request parameter parsing class in his com.oreilly.servlet
> package.  check out http://www.servlets.com/resources/index.html
> for more details.

Thanks, Paul.  I was just going to pipe in.  I had the same problem
previously so I wrote a ParameterParser class where you can call just

int pos = parser.getIntParameter("Position");

It will throw an exception in case the param can't be converted to an
int, so you may want to simplify the code with

int pos = parser.getIntParameter("Position", DEFAULT_POSITION);

Paul gave the URL already.  There's other goodies there, all covered in
the book.  I'm working on enhancements for rev2 of the book, so if you
have suggestions...

-jh-

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to