On the hosting page, set up a link like
<a href="download.jsp">Download as CSV file</a>
then in the new download.jsp file using the same resultset object you used for the grid display do a loop like. I am assuming htat you keep the result set object in a bean or something. Otherwise you'll have to re-run the query.
rs.moveFirst(); // Since you've probably already moved through the entire set on the grid page
// Output the column names
for( int i = 1; i <= rs.getColumnCount(); i++ )
{
out.println( rs.getColumnName(i) );
}
// Output the data
while( rs.next() )
{
out.println( rs.getString( "Your Field Name Here" ) +"," + ... repeat for all columns);
}
the browser should take acre of the file transfer part of this
|