Joe <sf***@spamcop.net> wrote in message news:<MP************************@sfo.news.speakeas y.net>...
In article <c8*************************@posting.google.com> ,
Di***********@hotmail.com says... I want to know if there is a way to check wether an HTML form field was
defined.
I think I'd do it this way:
public isDefined(HttpServletRequest req, String fieldNameToSearchFor) {
return req.getParameterMap().containsKey(fieldNameToSearc hFor);
}
Joe, your a life saver. before I saw your post I popped all of the
results into an enumeration list and checked them manually. Your ways
is Definately much better. Thanks
public boolean isFormFieldDefined(HttpServletRequest request, String
x)
throws ServletException, IOException
{
String tests = "a";
String chkfield = x;
boolean def = false;
Enumeration enum = request.getParameterNames();
while (enum.hasMoreElements())
{
tests = (String)enum.nextElement();
if(tests.equals(chkfield))
{
def = true;
break;
}
}
return def;
}//end isFormFieldDefined.