Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

jsp getParameter() null issue 2

Status
Not open for further replies.

DoraC

Programmer
May 7, 2002
98
US
Hi,

In my jsp code, I have three text boxes, defined in the following manner (but all three are within the form/table, vs. the one shown below):

Code:
<form method=&quot;get&quot;>
  <table border=&quot;0&quot; width=&quot;700&quot;>
    <tr>
      <td width=&quot;550&quot;>
        <input type=&quot;text&quot; name=&quot;sAccount&quot; size=&quot;25&quot;>
      </td>
    </tr>

...

    <tr>
      <td width=&quot;550&quot;>
        <input type=&quot;submit&quot; value=&quot;Submit&quot;>
      </td>
    </tr>
  </table>
</form>

I test them for &quot;nullness&quot; as so:
Code:
if ( request.getParameter(&quot;sAccount&quot;) == null )
{
%>
can't be null...
<%
};

if ( request.getParameter(&quot;sPassword&quot;) == null )
{
%>
can't be null...
<%
};

if ( request.getParameter(&quot;sDatabase&quot;) == null )
{
%>
database can't be null...
<%
};

Now, they always come up as non-null, even if I don't enter any value... I tried testing against &quot;&quot;, and got the same result. They DO register as being null when the page is first displayed, but whenever &quot;submit&quot; is clicked, they are mysteriously non-null (I even displayed the getParameter result, and it appeared to be the empty string, so nothing strange is getting imported).
 
Code:
String sreq = request.getParameter(&quot;sAccount&quot;);
if ( null == sreq || 0 == sreq.length() )

-pete
 

String sreq = request.getParameter(&quot;sAccount&quot;);
if ( null == sreq || 0 == sreq.trim().length() )



Salih Sipahi
Software Engineer.
City of Istanbul Turkey
s.sipahi@sahinlerholding.com.tr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top