File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes File downloading issue with Tmcat 6.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "File downloading issue with Tmcat 6.0" Watch "File downloading issue with Tmcat 6.0" New topic

File downloading issue with Tmcat 6.0

jagan bisoyi

Joined: Mar 09, 2008
Posts: 15
Hi.. Buddies!

I stuck in a problem as below:

I am using struts2 with tomcat6.0.1in netbeans 6.1 with jdk1.6 and ApachePOI.

User has to view data in tabular format based on a search criteria and can download the viewing table of the jsp page in excel sheet to his/her system.

So I am creating excel sheet when the user presses view button . the code gets executed inside ActionForm class itself.

My method to create excelsheet is:

private void createExcel(String filename,String[] rowdata, String[] column) {
try {
System.out.println("create excel file is called kbfksdjsdjksdfjsdfjsdfjsdjsdfsj");

File file=new File(filename);
filepath=file.getCanonicalPath(); in=new"Aakash_project/Downloads/brandnewExcelfile.xls").openStream())); fos = new"Aakash_project/Downloads/brandnewExcelfile.xls "); bout = new BufferedOutputStream(fos,1024);

System.out.println("path of the file is"+filepath);

WorkbookSettings ws = new WorkbookSettings();
ws.setLocale(new Locale("en", "EN"));
WritableWorkbook workbook =Workbook.createWorkbook(file, ws);
WritableSheet s = workbook.createSheet("completesheet", 0);

} catch (IOException e) {
} catch (WriteException e) {

private static void writeDataSheet(WritableSheet s,String[] rowdata,String[] headers)
throws WriteException {
System.out.println("coming to writeDataSheet");
for(int i=0;i<headers.length;i++){
System.out.println("coming to writeDataSheet"+rowdata[i]);
System.out.println("coming to writeDataSheet"+headers[i]);

//get the no of columns
System.out.println("length of header is"+headers.length);
System.out.println("length of row is"+rowdata.length);
for (int i=0;i<rowdata.length;i++){
int nc=headers.length;
int rows=rowdata.length/nc;
/* Format the Font */

WritableFont wf = new WritableFont(WritableFont.ARIAL,
10, WritableFont.BOLD);
WritableCellFormat cf = new WritableCellFormat(wf);
Label l ;

/* Creates Label and writes date to first row of sheet*/
for(int i=0;i<headers.length;i++){
l = new Label(i, 0,headers[i].toString() , cf);
int k=0;

for(int j=1;j<rowdata.length/7;j++){
for(int m=0;m<7;m++){
l = new Label(m,j,rowdata[k].toString());



look at the bold lines. The file should create there and I can also give an anchor tag containing the above path so that the user can able to download from there.

As it�s not creating there neither I am able to provide the anchor tag path., nor I can give the absolute path in the anchor tag as C:\program files\tomcat\bin because fire fox is telling it�s not a valid protocol..

I am stuck here.

Hope the above description will help to understand my problem and to solve it.

Thanks for any anticipation.
I agree. Here's the link:
subject: File downloading issue with Tmcat 6.0