wood burning stoves 2.0*
The moose likes JSP and the fly likes Open .csv file within jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Open .csv file within jsp" Watch "Open .csv file within jsp" New topic

Open .csv file within jsp

uday chovatiya

Joined: Aug 22, 2001
Posts: 2
Hi All,
I have a .csv file being created be back end in server. I am trying to open this file within jsp in Excel. I could display .xsl file in JSP by changin the content type attribute of page directive. But I could not find the way do following in jsp: 1)read this .csv file. 2)open the excel. 3)open this file in Excel. Your prompt response is highly appriciated. Thanks in advance
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
Which content type did you try for CSV?
If I remember correctly, you should use something like "application/csv" instead of "text/csv".

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Philip Shanks
Ranch Hand

Joined: Oct 15, 2002
Posts: 189
Here's what I do:
<%@page contentType="text/x-csv" session='true' errorPage='error.jsp'%>
and then, after I have set a variable up as a filename for download purposes,
<%response.setHeader("Content-disposition","filename=" + type + ".csv"); %>
This ensures that the client gets a "save or open" prompt, and provides the save case with a default filename.
[ April 22, 2003: Message edited by: Philip Shanks ]

Philip Shanks, SCJP - Castro Valley, CA
My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
I agree. Here's the link: http://aspose.com/file-tools
subject: Open .csv file within jsp
Similar Threads
Export data from Jsp to Excel taking more load time
Resultset to CSV
opening xls fine in web Browser using jsp
excel from java
Displaying Greek characters in Excel