All this answers to this we pretty much the same. If
Request.Form("myFormElement") returns a null object reference the code will
throw a NullPointerException. The reason is you have no object on which to
execute methods. So you would be better of doing the following
if ("myString".equals(Request.Form("myFormElement")))
Now if Request.Form("myFormElement") returns a null the code will still work.
"Chris Mcgarel" <[EMAIL PROTECTED]> on 08/27/99 11:41:37 AM
Please respond to [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
cc: (bcc: Robert Voysey/Inv/MetLife/US)
Subject: JSP Form
Can someone expalin to a novice why I must use:
if (Request.Form("myFormElement").equals("myString"))
rather than a straight comparison operator:
if (Request.Form("myFormElement")=="myString")
?
The latter does not work for me even though both left and right sides of the
statement are Strings.
The full code for form.jsp is:
<body>ody bgcolor=darkblue text=white>
<font face=arial>
<%
String myTest = "";
myTest = Request.Form("mySubmit");
if (myTest=="Click") // doesn't work, must be if
(myTest.equals("Click"))
{
out.println ("CLICKED!!!");
}
%>
<form action="form.jsp">
<input type=submit name="mySubmit" value="Click">
</form>
</font>
</body>
===========================================================================
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
===========================================================================
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