It's wasting server time. But it's probably saving your time if you somedays
reuse this code in another project. My opinion is that you should never rely
in any part of your code on the fact that things were smartly done in
another part.
I have lot of examples of this. For example, never assume that a path has a
trailing slash even if you provided it. Always test for it. Never assume
parameters are well formed, even you provide them. Always validate. And
never assume a parameter will never be null. Test it against null. It
doesn't cost much and can save you hours of bug traking later.
Pierre-Yves
-----Message d'origine-----
De : A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]De la part de FU
Envoyé : jeudi 26 avril 2001 10:40
À : [EMAIL PROTECTED]
Objet : Is this wasting ??
Hi there,
This is Fumitada.
I've made a way simple jsp retreiving one parameter and html...
< a snippet of my HTML code>
....
<form action="/test1.jsp" method=post >
<input type=text name=name size=20>
<input type=submit name=submit value=submit>
</form>
...
< a snippet of my JSP code >
...
String name = request.getParameter("name");
if( name != null && name.trim().length() != 0 ){
do something...
}
....
As above shows, I'm checking the name variable is either null or not.
Is this wasting ??
How come I think this is even though I don't type in anything in the
form of the html and click submit button, the name variable in the JSP
code gets Length-0-String object...
if the variable never get null, I don't have to check the variable is
null or not.
but I'm NOT sure, so I'm asking this, anybody knows the variable from
HTML form never be NULL ??
Thank you.
Fumitada.
___________________________________________________________________________
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