views:

367

answers:

1

Exception log

javax.servlet.ServletException
at  org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
at org.apache.jsp.FileUploadFormatAdd_jsp._jspService(FileUploadFormatAdd_jsp.java:620)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

Some of extract of jsp code is given below

      </HEAD>
  <BODY leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor="#ffffff" onLoad="document.FileUploadFormatAdd.reqdFileFormatName.focus();">
 <FORM method=post name="FileUploadFormatAdd" action="FileUploadFormatAdd.jsp" onSubmit="return validate(this);" >
 <!-- end of standard header bar with logo -->
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
 <td width="1%" valign="top">
 <%-- Modified by Jasleen
  <!-- Left Menu Start -->
  <table border="0" width="100%" cellspacing="0" cellpadding="0">
   <tr>
    <td bgcolor="#dddddd" width="1%"><img src="images/transp.gif" height="1" width="160"></td>
   </tr>
   <tr>
    <td width="1%">
     <!-- Start of Header Menu -->

     <!-- End of Header Menu -->
    </td>
   </tr>
  </table>
  <!-- Left Menu End -->
  --%>
 </td>
 <td width="1%" valign="top">
  <!-- Spacer (Left Menu and Main) Start -->
  <table border="0" width="100%" cellspacing="0" cellpadding="0">
   <tr>
    <td width="1%"><img src="images/transp.gif" height="1" width="20"></td>
   </tr>
  </table>
 </td>
 <td width="99%" valign="top">
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
   <tr>

    <td class="pageheader">

      </td>
     </tr>
  </table>

  <hr color="#cccccc" size="0" noshade width="99%" align="center">

  <table border="0" width="100%" cellspacing="0" cellpadding="0">
   <td>
   FileFormatName
   <input type="text" name="reqdFileFormatName">
   </td>
  </table>


  <table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
  <td>Field Name</td>
  <td>Min Length</td>
  <td>Max Length</td>
  <td>Type</td>
  <td>Is Future Date Allowed</td>
  <td>Is Past Date Allowed</td>
  <td>Is Required Field</td>
  <td>Depends Upon Field Name</td>
  <td>Depends Upon Field Value(Comma Separated Values)</td>
  <td>Min Value</td>
  <td>Max Value</td>
  <td>Field Order</td>
  <td>Sql Query</td>
  </tr>

  <input type="hidden" name="noOfRows" value="<%=noOfRows%>">
  <%
  Iterator iterFieldValues=listOfFields.iterator();
  %>
  <%for (int i=0;i<noOfRows;i++){%>
  <tr>
  <%
  String fieldName=(String)iterFieldValues.next();
  %>
  <td>
  <input type="text"  name="<%="reqdFieldName"+i%>" value="<%=(fieldName!=null)?fieldName:""%>" size="20" MAXLENGTH="100">
  </td>
  <%
  String minLength=(String)iterFieldValues.next();
  %>
  <td>
  <input type="text"  name="<%="minLength"+i%>" value="<%=(minLength!=null)?minLength:""%>" size="10" MAXLENGTH="5">
  </td>
  <%
  String maxLength=(String)iterFieldValues.next();
  %>
  <td>
  <input type="text"  name="<%="maxLength"+i%>" value="<%=(maxLength!=null)?maxLength:""%>" size="10" MAXLENGTH="5"> 
  </td>
  <%
  String fieldType=(String)iterFieldValues.next();
  %>

  <td>
  <select name="<%="reqdType"+i%>" size="20" onchange='EnableFields(this.name)'> 
  <option value="">Select<option>
  <option value="CodeNo" <%=fieldType.equals("CodeNo")?"selected":"" %> >CodeNo</option>
  <option value="CodeNoSQl" <%=fieldType.equals("CodeNo")?"selected":"" %>>CodeNoSQl</option>
  <option value="Date(dd/mm/yyyy)" <%=fieldType.equals("Date(dd/mm/yyyy)")?"selected":"" %>>Date(dd/mm/yyyy)</option>
  <option value="Email" <%=fieldType.equals("Email")?"selected":"" %>>Email</option>
  <option value="Float" <%=fieldType.equals("Float")?"selected":"" %>>Float</option>
  <option value="Number" <%=fieldType.equals("Number")?"selected":"" %>>Number<option>
  <option value="Text" <%=fieldType.equals("Text")?"selected":"" %>>Text<option>
  </select>
  </td>

  <%
  String isFutureDateAllowedValue=(String)iterFieldValues.next();
  %>

  <td>
  <input type="checkBox" value="1"  name="<%="isFutureDateAllowed"+i%>" <%=isFutureDateAllowedValue.equals("1")?"checked":""%> disabled > 
  </td>
  <%
  String isPastDateAllowedValue=(String)iterFieldValues.next();
  %>
  <td>
  <input type="checkBox" value="1" name="<%="isPastDateAllowed"+i%>" <%=isPastDateAllowedValue.equals("1")?"checked":""%> disabled > 
  </td>
  <%
  String isReqdFieldValue=(String)iterFieldValues.next();
  %>

  <td>
  <input type="checkBox" value="1"  name="<%="isReqdField"+i%>" <%=isReqdFieldValue.equals("1")?"checked":""%>  > 
  </td>
  <%
  String dependsUponFieldName=(String)iterFieldValues.next();
  %>
  <td>
  <input type="text"  name="<%="dependsUponFieldName"+i%>" value="<%=(dependsUponFieldName!=null)?dependsUponFieldName:""%>" size="20" MAXLENGTH="100"> 
  </td>
  <%
  String dependsUponFieldValue=(String)iterFieldValues.next();
  %>
  <td>
  <input type="text"  name="<%="dependsUponFieldValue"+i%>" value="<%=(dependsUponFieldValue!=null)?dependsUponFieldValue:""%>" size="20" MAXLENGTH="500" >
  </td>
  <%
  String minValue=(String)iterFieldValues.next();
  %>
  <td>
  <input type="text"  name="<%="minValue"+i%>" value="<%=(minValue!=null)?minValue:""%>" size="10" MAXLENGTH="10">
  </td>
  <%
  String maxValue=(String)iterFieldValues.next();
  %>
  <td>
  <input type="text"  name="<%="maxValue"+i%>" value="<%=(maxValue!=null)?maxValue:""%>" size="10" MAXLENGTH="10">
  </td>
  <%
  String fieldOrder=(String)iterFieldValues.next();
  %>
  <td>
  <input type="text"  name="<%="reqdFieldOrder"+i%>" value="<%=(fieldOrder!=null)?fieldOrder:""%>" size="10" MAXLENGTH="3"> 
  </td>
  <%
  String sqlQuery=(String)iterFieldValues.next();
  %>

  <td>
  <input type="text"  name="<%="sqlQuery"+i%>" value="<%=(sqlQuery!=null)?sqlQuery:""%>" size="10" MAXLENGTH="1000" disabled> 
  </td>
  </tr>
  <%}%>

  <tr>
  </tr>
  </table>
  <input type="hidden" name="changeType" value="abc">
  <input name="addRow" type="button" value=" + "        onclick="this.form.changeType.value='addRow';document.FileUploadFormatAdd.submit()"></input>
  <input name="deleteRow" type="button" value=" - " onclick="this.form.changeType.value='deleteRow';document.FileUploadFormatAdd.submit()"></input>

+2  A: 

There is nothing behind the "javax.servlet.ServletException"? Any extra information in the server's logfile?

A first very suspicious point is this part of your code, with the HTML bits erased

Iterator iterFieldValues=listOfFields.iterator();
for (int i=0;i<noOfRows;i++){
    String fieldName=(String)iterFieldValues.next();
    String minLength=(String)iterFieldValues.next();
    String maxLength=(String)iterFieldValues.next();
    String fieldType=(String)iterFieldValues.next();
    ...
}

Are you really really sure you want to do that? Iterator and then walk through it with a for loop? Without hasNext() testing? Because next() will throw a NoSuchElementException when there's no next element.

fvu
+1 for actually reading and making sense out of this mess. When I started on my current project, most JSPs looked like this one in the OP ;(
Alexander Pogrebnyak
@Alexander - you have all my sympathy...
fvu
The code above is actually very clean and readable compared to quite a few of the projects I am working on ;-)
Guillaume