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:

...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). ...






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.
>
>
> > At 19:21 04/04/01 +0530, you wrote:
> > >The message of the story:
> > >In Java String class behaves like a primitive data type..
> > >
> > >hope it helps..
> > >
> > >thanks
> > >donny.
>
> 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

___________________________________________________________________________
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


--=_alternative 0061E14F85256A24_=
Content-Type: text/html; charset="us-ascii"


<br><font size=2 face="sans-serif">See Milton Epstein's tireless and
reliable explanation. Here's an excerpt:</font>
<br>
<br><font size=2><tt>...Well, this isn't really safe either, because you
should check whether<br>
it is null first. &nbsp;getParameter() can return null. &nbsp;It will do so
when<br>
the parameter does not exist (which is different than it being empty,<br>
which is what you're checking for above). ...</tt></font>
<br>
<br>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td>
<td><font size=1 face="sans-serif"><b>Gene Campbell
&lt;[EMAIL PROTECTED]&gt;</b></font>
<br><font size=1 face="sans-serif">Sent by: &quot;A mailing list for
discussion about Sun Microsystem's Java &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;Servlet API Technology.&quot;
&lt;[EMAIL PROTECTED]&gt;</font>
<p><font size=1 face="sans-serif">04/04/01 12:55 PM</font>
<br><font size=1 face="sans-serif">Please respond to &quot;A mailing list
for discussion about Sun Microsystem's Java &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp;Servlet API Technology.&quot;</font>
<br>
<td><font size=1 face="Arial">&nbsp; &nbsp; &nbsp; &nbsp; </font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; To: &nbsp;
&nbsp; &nbsp; &nbsp;[EMAIL PROTECTED]</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; cc: &nbsp;
&nbsp; &nbsp; &nbsp;</font>
<br><font size=1 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; Subject:
&nbsp; &nbsp; &nbsp; &nbsp;Re: Simple Problem....</font></table>
<br>
<br>
<br><font size=2><tt>Is there another issue here that I'm not getting from
the thread.<br>
</tt></font>
<br><font size=2><tt>It seem to me doing<br>
</tt></font>
<br><font size=2><tt>String val = req.getParameter
(&quot;paramName&quot;);<br>
</tt></font>
<br><font size=2><tt>if(val !=null &amp;&amp; val.length() &gt; 0)<br>
{<br>
 &nbsp; &nbsp;// &nbsp;The tag is valid<br>
}<br>
else<br>
{<br>
 &nbsp; &nbsp;// &nbsp;The tag isn't valid<br>
}<br>
</tt></font>
<br><font size=2><tt>will do it.<br>
</tt></font>
<br><font size=2><tt>Is there more?<br>
</tt></font>
<br><font size=2><tt>- gene<br>
</tt></font>
<br>
<br>
<br><font size=2><tt>----- Original Message -----<br>
From: &quot;Milt Epstein&quot; &lt;[EMAIL PROTECTED]&gt;<br>
To: &lt;[EMAIL PROTECTED]&gt;<br>
Sent: Wednesday, April 04, 2001 9:46 AM<br>
Subject: Re: Simple Problem....<br>
</tt></font>
<br>
<br><font size=2><tt>&gt; On Wed, 4 Apr 2001, Dominic O'Reirdan wrote:<br>
&gt;<br>
&gt; &gt; I just did this.<br>
&gt; &gt;<br>
&gt; &gt; if(req.getParameter(&quot;paramName&quot;).length() != 0) {<br>
&gt; &gt;<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;do your code<br>
&gt; &gt;<br>
&gt; &gt; } else {<br>
&gt; &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;throw an exception or
something<br>
&gt; &gt; }<br>
&gt;<br>
&gt; Well, this isn't really safe either, because you should check
whether<br>
&gt; it is null first. &nbsp;getParameter() can return null. &nbsp;It will
do so when<br>
&gt; the parameter does not exist (which is different than it being
empty,<br>
&gt; which is what you're checking for above).<br>
&gt;<br>
&gt; Now if you're always using parameter names that you know will exist
--<br>
&gt; i.e. you know they exist in the form, even if you don't know that
they<br>
&gt; will get set to anything -- then you won't run into any instances
of<br>
&gt; getParameter() returning null. &nbsp;But that's not really safe
programming<br>
&gt; style.<br>
&gt;<br>
&gt;<br>
&gt; &gt; At 19:21 04/04/01 +0530, you wrote:<br>
&gt; &gt; &gt;The message of the story:<br>
&gt; &gt; &gt;In Java String class behaves like a primitive data type..<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;hope it helps..<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;thanks<br>
&gt; &gt; &gt;donny.<br>
&gt;<br>
&gt; Milt Epstein<br>
&gt; Research Programmer<br>
&gt; Software/Systems Development Group<br>
&gt; Computing and Communications Services Office (CCSO)<br>
&gt; University of Illinois at Urbana-Champaign (UIUC)<br>
&gt; [EMAIL PROTECTED]<br>
&gt;<br>
&gt;<br>
___________________________________________________________________________<br>

&gt; To unsubscribe, send email to [EMAIL PROTECTED] and include in
the<br>
body<br>
&gt; of the message &quot;signoff SERVLET-INTEREST&quot;.<br>
&gt;<br>
&gt; Archives:
http://archives.java.sun.com/archives/servlet-interest.html<br>
&gt; Resources:
http://java.sun.com/products/servlet/external-resources.html<br>
&gt; LISTSERV Help: http://www.lsoft.com/manuals/user/user.html<br>
</tt></font>
<br><font size=2><tt>
___________________________________________________________________________<br>

To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body<br>
of the message &quot;signoff SERVLET-INTEREST&quot;.<br>
</tt></font>
<br><font size=2><tt>Archives:
http://archives.java.sun.com/archives/servlet-interest.html<br>
Resources: http://java.sun.com/products/servlet/external-resources.html<br>
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html</tt></font>
<br>
<br>
--=_alternative 0061E14F85256A24_=--

___________________________________________________________________________
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