File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Ccomma delimited file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Ccomma delimited file" Watch "Ccomma delimited file" New topic

Ccomma delimited file

brisk rook

Joined: Jul 19, 2001
Posts: 20
How do i generate a comma delimted file in a loop for a jsp file & post it to the screen to allow the user to save this file in Excel..
Sam Dalton
Ranch Hand

Joined: Jul 26, 2001
Posts: 170
set the content type to one appropriate type for excel
eg: response.setContentType("text/csv")


<a href="" target="_blank" rel="nofollow">Sam Dalton</a>,<br />Co-author of []Professional JSP 2.0[/URL] (October 2003)<br />Co-author of <a href="" target="_blank" rel="nofollow">Professional SCWCD Certification</a><br />Co-author of <a href="" target="_blank" rel="nofollow">Professional Java Servlets 2.3</a>
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16384

Or, do one better and actually feed the data straight into Excel, where the user can save it in the usual way. Instead of "text/csv", make your MIME type "application/x-msexcel". DON'T generate HTML, BTW, all you need to write are lines of comma-separated text, just like you would from a regular application.

Customer surveys are for companies who didn't pay proper attention to begin with.
It is sorta covered in the JavaRanch Style Guide.
subject: Ccomma delimited file