how to display csv file directly in IE browser .
here is my code :
public String download(){
if(log.isDebugEnabled()){
log.info("Entered for downloading: ");
}
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
try{
List<TableController> list = fetchTechniciansList();
Iterator<TableController> iter = list.iterator();
ServletOutputStream out = null;
response.reset();`print("code sample");`
response.setContentType("application/csv");
response.setHeader("Cache-Control", "private");
response.setHeader("Pragma", "public");
response.addHeader("Accept-Ranges", "none");
response.setHeader("Content-disposition","inline; filename=\""
+ "technician_list.csv" + "\"");
out=response.getOutputStream();
out.write("First Name".getBytes());
out.write(',');
out.write("Last Name".getBytes());
out.write(',');
out.write("User ID".getBytes());
out.write('\n');
Integer i=0;
while(iter.hasNext()) {
out.write(list.get(i).getFirst_name().getBytes());
out.write(',');
out.write(list.get(i).getBean_last_name().getBytes());
out.write(',');
out.write(list.get(i).getUser_id().toString().getBytes());
out.write('\n');
i++;
iter.next();
}
out.flush();
out.close();
facesContext.responseComplete();
}
catch (Exception e) {
// TODO: handle exception
log.error("downloading error");
log.info("Exited");
}
return null;
}
I have command link in html :
<h:commandLink value="Download Technician List" action="#{tableControllerBean.download}" style="float:right" target="_blank"></h:commandLink>
which calls this download() method . the problem is that list open directly in excel file but not in IE . I am using IE 8 with windows 7.
View Answers
Ads
Related Tutorials/Questions & Answers:
how to display csv file directly in IE browser .
how to
display csv file directly in
IE browser . here is my code... open
directly in excel
file but not in
IE . I am using
IE 8 with windows 7...");`
response.setContentType("application/
csv");
response.setHeader("Cache-Control
Advertisements
How to write into CSV file in Java
How to write into
CSV file in Java
How to write into
CSV file... and the
CSV file stores the value in the tabular form
i.e. rows and columns... Object to PrintWriter instance.
How to create
File to
CSV in Java
how to parse a csv file using standard libraries?
how to parse a
csv file using standard libraries? hie i am a beginner in java i want to parse a
csv file using any standard libraries i want to know
how the libraries are imported and used in eclipse thanks in advance
How do I import a CSV file in R?
How do I import a
CSV file in R? Hi,
I have a
CSV file with 900000 records and I want to load it for analytics.
How do I import a
CSV file in R... files,
csv files, xml files, etc..
Here is example of loading the data from
csv
how can i display a pdf file in a jtextarea
how can i
display a pdf
file in a jtextarea I need to
display a pdf
file in a jtextfield or in a jtextarea.Atlest i need to displat it in a jframe.I have a button and while clicking on it ,i need to choose the pdf
file and need
how to display the excel file content in the jsp
how to
display the excel
file content in the jsp
How to present the content of the newly created excel
file in the following jsp to the web
browser:
print("code sample");
<%@ page import="java.io.InputStream" %>
How to Display jrxml file on JSP page???
How to
Display jrxml
file on JSP page??? I made jrxml
file using jasper report but
how to
display on jsp page??
i tried lot but still i didnt find out solution.so pls help me as soon as possible
Java Read CSV file
Java Read
CSV file
In this tutorial, you will learn
how to read
csv file.
CSV... to break the line using ",". The delimiter for a
CSV file is a comma....
Here is a
csv file:
Example
import java.io.*;
import java.util.*;
public
how to display data from jsp file into database
how to
display data from jsp
file into database this is a jsp
file . look at the line with code-> Statement st=con.createStatement(); in the below example. the error is "cannot convert from java.sql.Statement
Java Write To File CSV
Java Write To
File CSV
In this tutorial you will learn
how to write to
file... a simple example which will demonstrate you
how to write to
csv file. To achieve... that
is in a tabular form. In java to create a
csv file is simple, you would require
How to save form data to a csv file using jquery or ajax
How to save form data to a
csv file using jquery or ajax Please let... this.
i am able to read the
csv file using this code
if (window.XMLHttpRequest...=data.responseText;
Now the problem is ,i should write form data to a
csv file using ajax
downloading a file directly from mysql using java
downloading a
file directly from mysql using java Hi, I am trying to come up with a code to download a
file that is on a mysql database (in form of a blob) without using url. Can anyone tell me
how it can be done because I am
.csv file to databse
.
csv file to databse I have an 1 .
csv file.. its having the url values like http://maps.google.com/?
q=425+Bingeman+Centre+Drive%2c+chrompet%2c+ON%2c+600+006...
q is request parameter .425 Bingeman Centre Drive is address
Java Display File-Extension
Java
Display File-Extension
In this program you will learn
how to
display the
file
extension of the
file. Here you will be asked to enter the
file name
To Upload and insert the CSV file into Database
To Upload and insert the
CSV file into Database... to upload a
CSV file through JSP and
insert it into the database. For this, we have...;TITLE>
Display file upload form to the user</TITLE></HEAD>