• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Downloading from JSP

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I got it working able to download a text file from JSP page..My problem is :
when the download box pops up (Save/Open),it has got following funny lines..
--
You have choosen to download from this location submit.jsp(name of the jsp file) <url>
--
Instead of the jsp file name(submit.jsp) I want it to display the name of downloaded text file..
I using following setting thanks to prevous postes messages..
<%@ page contentType="application/octet-stream" buffer="216k" autoFlush="true" %>
response.setHeader("Content-Disposition","attachment;filename=\"BoralInvoice.txt\"");
Any help is highly appreciated
Raj
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Raj,
I am sorry that I am not helping you in any way but I want to ask you how have you downloaded txt file using JSP?
Thanks in advance
Smita
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Raj,
U can use the following code . I tried it in netscape and iexplorer .it works fine . I would like to just point out the thing that if it(browser) is not able to find the text file it will open the jsp file .

------------------
Sandeep Jain
 
Sandeep Jain
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry ,I forgot to paste the code
<html>
<%@ page contentType="multipart/x-zip" autoFlush="true" %>
<% response.setHeader("Pragma","no-cache"); %>
<% response.setHeader("Expires", "0"); %>
<% response.setHeader("Content-Disposition", "attachment;filename=\"BoralInvoice.txt\""); %>
</html>

------------------
Sandeep Jain
 
Raj Sethi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Thanks for your help..I tried your code it is the same ,may be I think my question was not clear ..
In my jsp page for downloading I'm NOT reading from any existing file,it dynamically generates data and WRITES to out object..
I think your code might work if it has to read from a file and write to out object ..corrrect me if I'm wrong .
could you pls. explain what is the purpose of using "pragma","expires" in header ..
Thanks again
Raj
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sandeep thank you for your code
but when i used your code to download a resource, the dialog box showed it would download the jsp file, and as i press 'ok', the "save as" dialog box just showed the resource i required to download. the problem is that after do the download, the saved files are of the same size, 29 bytes. i wonder why this happened.
and i use tomcat4 and ie5. thanks again
 
There's a hole in the bucket, dear Liza, dear Liza, a hole in the bucket, dear liza, a tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic