aspose file tools*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "File downloading issue with Tmcat 6.0" Watch "File downloading issue with Tmcat 6.0" New topic
Author

File downloading issue with Tmcat 6.0

jagan bisoyi
Greenhorn

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();
java.io.BufferedInputStream in=new java.io.BufferedInputStream((new java.net.URL("Aakash_project/Downloads/brandnewExcelfile.xls").openStream()));
java.io.FileOutputStream fos = new java.io.FileOutputStream("Aakash_project/Downloads/brandnewExcelfile.xls ");
java.io.BufferedOutputStream 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);
writeDataSheet(s,rowdata,column);
workbook.write();
workbook.close();

} catch (IOException e) {
e.printStackTrace();
} catch (WriteException e) {
e.printStackTrace();
}
}

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++){
System.out.println(rowdata[i].toString());
}
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);
cf.setWrap(true);
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);
s.addCell(l);
}
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());
System.out.print(k+"harekrishna"+rowdata[k].toString());
s.addCell(l);
if(k<(rowdata.length-1)){
k++;
}

}
}


}


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.
jagan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File downloading issue with Tmcat 6.0
 
Similar Threads
Printing contents
Please help for this Problem in creating excel sheet using java
jExcelAPI: How to change format cells text in excel as general format
Writing a content in excel in incremental way
importing data from database to excel sheet through JExcel Api