Several questions about getParameterValues

Category: Web Develop
 
hedegao
2008-09-27 05:53:56

Sponsored Links
<form action="" method="post">
<tr> <td align = "right" height = "32" width = "40%"> login name: </td>
<td>
<input type="text" name="logname" value="">
</td>
</tr>
<tr>
<td align="right" height="32"> E_mail: </td>
; <td>
<input type = "text" name = "email">
</td>
</tr>
; <tr> <td colspan="2" align="center">
; <input type="submit" value=" " name="findpass">
1 <form action = "" method = "post">
where action is empty, visit the post after is how it works? This page is not control their own A getParameterValues ​​if the page has something like it! !
2 page that contains the above code also contains the following code:
<%
String [] b = request.getParameterValues ​​("findpass");
/ / boolean bb = request.getParameterValues ​​("findpass") [0]. trim (). equals ("Retrieve Password"); why there can not be performed, an executive on java.lang.NullPointerException, and the following IF Conditions judgment can be performed, and no exception occurs? ?
String [] cc = request.getParameterValues ​​("logname");
String [] dd = request.getParameterValues ​​("email");
String temp11 = request.getParameterValues ​​("findpass") [0]. trim () ;/ / phrase also performed on abnormal
if (request.getParameterValues ​​("findpass")! = null
& ; & request.getParameterValues ​​("findpass") [0]. trim (). equals ("Retrieve Password")
&& request.getParameterValues ​​("logname") ;! = null
&& request.getParameterValues ​​("email")! = null)

3getParameterValues ​​returns an array, how to view his value, I tried
String [] b = request.getParameterValues ​​("findpass");
String [] cc = request.getParameterValues ​​("logname");

String temp22 = b [0];
String temp33 = b [1];

not work,

Sponsored Links

zhangwang117
2008-09-27 05:56:10
1, action is itself is pointing to an empty page where
2, because when you get is null, can not be used. trim () instance method, etc., with a NullPointerException will be thrown
3, used for (int ; i = 0; i <b.length; i + +) {
out.println (b [i]);
}
not because you're using to get the request.getParameterValues ​​("findpass"); instead of an array may be empty because
linuxLife123456
2008-09-27 06:07:31
boolean bb = b [0] . trim (). equals ("Retrieve Password");

if (request.getParameterValues ​​("findpass")! = null) / / Here is the entire array does not judge is empty, while the single element in the decision tree group, you then write is wrong, I think.
wy790867270
2008-09-27 06:17:05
why there can not be performed, an executive on java.lang.NullPointerException, the following IF condition judgment can be performed, and no exception occurs? ?
dfqwertiyu5678321452
2008-09-27 06:20:50
String [] b = request.getParameterValues ​​("findpass");

/ / before executing the next sentence should first determine request.getParameterValues ​​("findpass") ! = null

boolean bb = request.getParameterValues ​​("findpass") [0]. trim (). equals ("Retrieve Password");

String [] cc = request.getParameterValues ​​("logname");
String [] dd = request.getParameterValues ​​("email");

/ / same before executing the next sentence should first determine request.getParameterValues ​​("findpass")! = null

String temp11 = request.getParameterValues ​​("findpass") [0]. trim ();

Below these are nonsense. Not have been given the value of it?
if (request.getParameterValues ​​("findpass")! = null
&& request.getParameterValues ​​("findpass") [0]. trim (). equals (" ; Forget password ")
&& request.getParameterValues ​​(" logname ")! = null
&& request.getParameterValues ​​(" email ") ! = null)
q11057672
2008-09-27 06:34:46
long as the judge, whether it is in session or request the nullPointerException never thrown.
unless you decide to fake his own way should be removed.
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.