I have an HTML page with links to several files in the server. The goal is :
when the user clicks on one of these links, he can download it (I mean, that
the browser should open the dialog that says "open from its current
location" or "save the file in disk")
The problem is that these links don't have a pointer to a real file on the
server, but to a servlet, wich is responsible to generate the file and send
it to the browser. The file format could is unpredictable: xls, zip, txt,
autocad file, html, pdf and so on. I don't know thw content type of the
file.
What I am doing now is:
byte[] oFile = generate a byte[] with the actual file content
ServletOutputStream out = response.getOutputStream();
out.write(oFile);
out.flush();
I have 3 problems:
a) I have the file name in the servlet, but I don't know how to send it to
the browser.
b) If the browser recognizes the file (ie txt, gif or html): it displays it
on the current browser window.(something I want to avoid)
c) If the browser doesn't recognize the file (ie zip, xls...), it opens the
dialog to save it. If the user chooses "save the file in disk", it gives as
default name "programad63e5b8d.txt" (servlet's name the links point to is
called "programa"). If the user chooses "open from its current location", it
opens it with notepad.
Ideas are appreciated.
--------------
Oscar Guindzberg
[EMAIL PROTECTED]
++54-11-4345-0537 (int. 132)
Java Development Team
Soluciones Integrales S.A.
Buenos Aires - Argentina
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html