On Wed, 4 Apr 2001, Larry Chung wrote:
> This is a multipart message in MIME format.
> --=_alternative 0061E14F85256A24_=
> Content-Type: text/plain; charset="us-ascii"
>
> See Milton Epstein's tireless and reliable explanation. Here's an
> excerpt:
Thanks :-). I didn't want to post so much on this relatively simple
and straightforward issue, but a number of comments/suggestions were
incorrect and/or misleading, and I felt that some
corrections/clarifications were called for.
> ...Well, this isn't really safe either, because you should check whether
> it is null first. getParameter() can return null. It will do so when
> the parameter does not exist (which is different than it being empty,
> which is what you're checking for above). ...
Actually, though, what Gene Campbell posted is OK. He first checks
that it's non-null, then that it's non-empty. It's one of the two
formats I suggested in a number of my posts in the thread.
> Gene Campbell <[EMAIL PROTECTED]>
> Sent by: "A mailing list for discussion about Sun Microsystem's Java
> Servlet API Technology." <[EMAIL PROTECTED]>
> 04/04/01 12:55 PM
> Please respond to "A mailing list for discussion about Sun Microsystem's
> Java Servlet API Technology."
>
>
> To: [EMAIL PROTECTED]
> cc:
> Subject: Re: Simple Problem....
>
>
> Is there another issue here that I'm not getting from the thread.
>
> It seem to me doing
>
> String val = req.getParameter("paramName");
>
> if(val !=null && val.length() > 0)
> {
> // The tag is valid
> }
> else
> {
> // The tag isn't valid
> }
>
> will do it.
>
> Is there more?
>
> - gene
>
>
>
> ----- Original Message -----
> From: "Milt Epstein" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, April 04, 2001 9:46 AM
> Subject: Re: Simple Problem....
>
>
> > On Wed, 4 Apr 2001, Dominic O'Reirdan wrote:
> >
> > > I just did this.
> > >
> > > if(req.getParameter("paramName").length() != 0) {
> > >
> > > do your code
> > >
> > > } else {
> > > throw an exception or something
> > > }
> >
> > Well, this isn't really safe either, because you should check whether
> > it is null first. getParameter() can return null. It will do so when
> > the parameter does not exist (which is different than it being empty,
> > which is what you're checking for above).
> >
> > Now if you're always using parameter names that you know will exist --
> > i.e. you know they exist in the form, even if you don't know that they
> > will get set to anything -- then you won't run into any instances of
> > getParameter() returning null. But that's not really safe programming
> > style.
[ ... ]
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