Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

File downloading issue with Tmcat 6.0

Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic