Heap Space Exception on Downloading a File
<p>I have an application in which if i download few entries , then the downloading of my csv file is  working fine....but if there are lot many entries, there is java exception  and on debugging it is giving vmdisconnected exception.
I am trying to get all the data in a variable named</p>

<pre><code>String content = service.generateCSV(SearchVO);
</code></pre>

<p>this content variable is set in action class  and then i have a downloadservlet class in which i am getting this content variable.</p>

<pre><code>String content = (String) request.getAttribute(CONTENT);
</code></pre>

<p>Can anyone suggest me how to read the content in a way that so  i can download a file even if it has lot many entries</p>

<p>This is how i am getting data from database</p>

<pre><code>    `while (sqlRowSet.next()) 
        {
  data = (DB2Xml) sqlRowSet.getObject(Constants.TABLE_NAME_XML);
   dl = data.getDB2XmlString();}
</code></pre>

<p>The stack trace:-</p>

<pre><code>java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Unknown Source)
at java.lang.String.&lt;init&gt;(Unknown Source)
at java.lang.StringBuffer.toString(Unknown Source)
at com.ibm.db2.jcc.c.fc.getDB2XmlString(fc.java:187)
</code></pre>
