Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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: 17410

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.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Ccomma delimited file
jQuery in Action, 3rd edition