-1

i'm working with struts 1.3 project with jsp file that works as to extract the Excel file, but i get error when the data in excel file is huge i.e more than 10000.

here is the code snippet with error :

Below is the error :

HTTP Status 500 - An exception occurred processing JSP page /pages/console/popUpExcell.jsp at 
line 14
 ________________________________________
type Exception report
message An exception occurred processing JSP page /pages/console/popUpExcell.jsp at line 14
description The server encountered an internal error that prevented it from fulfilling request.
exception
org.apache.jasper.JasperException:Feb 25, 2014 6:20:33 PM    org.apache.catalina.core.StandardWrapperValve invoke
   SEVERE: Servlet.service() for servlet [jsp] in context with path [/project] threw exception   [An exception occurred processing JSP page /pages/console/popUpExcell.jsp at line 15     11: 
 12: String cadena = request.getParameter("cadena");
 13: System.out.println("cd="+cadena);
 14: cadena=cadena.replaceAll("<INPUT type=checkbox name=validar>","");
 15: response.containsHeader("application/vnd.ms-excel");
 16: response.setContentType("application/vnd.ms-excel");
 17: response.setHeader ("Content-Disposition", "attachment;filename=file1.xls");
 Stacktrace:
 org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
 org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
 root cause
 java.lang.NullPointerException
 org.apache.jsp.pages.console.popUpExcell_jsp._jspService(popUpExcell_jsp.java:84)

Here error occurs when there is huge data i.e. more than 10000. but if the data is less than it works properly.

i.e when list of data is more String cadena = request.getParameter("cadena") gives me null and when list of data is less then works properly

file popUpExcell.jsp

 <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ page contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
  <HTML>
  <HEAD>
  <TITLE>
  </TITLE>
  </HEAD>

   <body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">      
   <% 
    String cadena = request.getParameter("cadena");
   System.out.println("cd="+cadena);
   cadena=cadena.replaceAll("<INPUT type=checkbox name=validar>","");
 response.containsHeader("application/vnd.ms-excel");
 response.setContentType("application/vnd.ms-excel");
 response.setHeader ("Content-Disposition", "attachment;filename=file1.xls");
  %>
 <table  border="1" bordercolorLight="blue" cellspacing="0" cellpadding="2" style="border:      solid #000000; background color:#ffffff;table-layout:auto;">
<tr bgcolor="#333399">
<td align="center"class="Text222" width="20"     >&nbsp;</td>
<td align="center"  width="70" class="blanco"><bean:message key="menu"/></td>
<td align="center" width="90" class="blanco"><bean:message key="menu.type"/></td>
<td align="center" width="200" class="blanco"><bean:message key="menu.location"/></td>
<td align="center" width="200" class="blanco"><bean:message key="menu.detail"/></td>
<td align="center" width="170" class="blanco"><bean:message key="menu.customer"/></td>
<td align="center" width="200" class="blanco"><bean:message key="menu.zipcode"/></td>
<td align="center" width="180" class="blanco"><bean:message key="menu.destination"/></td>
<td align="center" width="110" class="blanco"><bean:message key="menu.status"/></td>
<td align="center" width="90" class="blanco"><bean:message key="menu.Logdate"/></td>
<td align="center" width="170" class="blanco"><bean:message key="menu.vendor"/></td>

</tr>
     </table>
   <%=cadena %>

i'm using a javascript function i.e on click of a button export excel appers :

 function fnCopyReportTable()
        {
            cadena=frames.frameId.document.all.listTable.innerHTML;
            alert(cadena);  // here it displays HTML DOM
            document.form1.cadena.value=cadena;
            form1.action="<%=request.getContextPath()%>/pages/file/popUpExcell.jsp";
            form1.submit();
        }

Here the list contains export to excel sheet. But this above problem i face when <%=cadena%> contains large data. cadena refers HTML DOM in it. want to solve the error when there is large data in it.

techGaurdian
  • 732
  • 1
  • 14
  • 35
  • Where is this: `popUpExcell_jsp.java:84` – Justin Jasmann Feb 25 '14 at 13:40
  • I doubt is it working with less data !! Its not about the amount of data. – Vinay Veluri Feb 25 '14 at 13:42
  • There is a maximum size for parameters submitted to the web server. Would I be right in thinking that you are using a GET request? This would explain the small size of your parameter. This is related to HTTP parameter sizes: http://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request – beny23 Feb 25 '14 at 13:43
  • its working file when data is around 500 but gives me above error when data is large i.e 7000 (ex.when i need export file for a particular status "Linked" contains less data around 300. and it works fine ) but when i want to export file for status "Delivered" contains more data around 8000 it gives me above error. – techGaurdian Feb 25 '14 at 13:48
  • @ beny23: hi. i checked it by request.getMethod() (which prints POST on console screen); – techGaurdian Feb 25 '14 at 13:51
  • i have edited by question: when i click on a button export excel appers and here cadena=frames.frameId.document.all.listTable.innerHTML – techGaurdian Feb 25 '14 at 14:23
  • now i am setting maxPostSize="0" (unlimited size) or set size maxPostSize="67589953" in the Tomcat's server.xml Connector Component. No Error occurs. But here Excel Sheet Stops at the end (i think its due to Excel Sheet conatins large data). – techGaurdian Feb 26 '14 at 08:32
  • @Responsible for -ve mark: May i kno the reason why this question being negatively marked. As i did put in effort for conveying the question to an extent. thank you. – techGaurdian Mar 18 '14 at 09:06

1 Answers1

0

On load of JSP, the request object cannot find the parameter cadena.

So,

String cadena = request.getParameter("cadena");

gives you null.

Wrap the content over saying that,

if(request.getMethod().equals("POST") or if(request.getMethod().equals("GET")

so that, JSP will execute the content only if the page is called.

Vinay Veluri
  • 6,671
  • 5
  • 32
  • 56