This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
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

Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
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: 16160

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.
I agree. Here's the link:
subject: Ccomma delimited file