• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP download

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My jsp page contains a button which exports data to an excel sheet. The excel file is being saved on the server.
How can i save the file directly on the client.
[ June 16, 2005: Message edited by: Ankit Pedro ]
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

How can i save the file directly on the client.



You cannot save it directly to the client. Think of the nightmare that would ensue if every server could just write whatever it wanted to your computer.

The viable approach is to offer the report for download. If the file exists on the server in a place accessible to the web server, this could be as simple as creating a link (using the <a> tag) to that file.

Otherwise, you could write a servlet that streams the file to the client after setting the correct content and disposition headers.
 
Ankit Pedro
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Bear,

The case that I am facing is :

When the administrator checks a time sheet, a buton ( export to excel ) saves the time sheet on the client. The time sheet data are not in a file on the web server the are in a database.

I was thinking when pressing the button, the data first gets saved on the server as .xls file then downloaded to the client.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Set the content type (to tell the browser what kind of file this is).

Set the content disposition (to tell the browser what the name of the file is to be and whether to prompt for a location to save to 'attachment' or to open the associated application 'Excel' right in the browser 'inline'.

Then parse your data into delimited lines or an HTML Table).
[ June 17, 2005: Message edited by: Ben Souther ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic