Jeetandra Mahtani wrote:

> Hello - We have a search form where users enter several parameters. The results page
> displays the values retrieved in a fixed format. Is it possible to give the users an
> option to download the results in a CSV file ( so that they can open it in Excel or 
>so).
> Something like when they click on the submit button of the form, rather then 
>displaying
> the results page, bring up a save dialot to save the generated CSV file.
> Appreciate it if anyone can give me any ideas on how to implement this or point me 
>to a
> site which gives me more information on how to implement this?
> Thanks,
> J
>

This one is really easy -- it is a simple matter of setting the content type of the
response before you start writing, like this:

    response.setContentType("text/plain");
    PrintWriter writer = response.getWriter();
    writer.println(...);
    ...

Doing this will cause the output to be displayed in a fixed font in the browser 
window.  If
you know that your users are running Windows with MS-Office installed, you can also 
cause
the output file to automatically start MS Excel, for example, by using a content type 
of
"application/ms-excel".  The only requirement is that the user have this mapped to the
corresponding application in their browser configuration.

Craig McClanahan

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to