Hi Edwin,
Thanks for the tip. I'm going to try it now and keep you informed
about the results.
Still, my questions remain.
When I wrote that an 'Information' window appears informing 'Download
complete' that doesn't mean that the download was successful. In fact,
the download didn't occur but that particular window appears. Why?
The other two questions aren't answered yet:
why is 'winzip70.exe' referred as 'Down72d063a0'?
In the 'Save As' window, why is the file referred as '.Document' type?
This is becoming a red flag situation.
===
Joao Carlos Costa
---Edwin Smith <[EMAIL PROTECTED]> wrote:
>
>
res.setHeader("Content-Disposition","attachment;filename="+getParameter(req,
> myfilename));
>
> you may need a space after "attachment" and you might need
> to encode the filename (not positive, i'm shooting from the hip :-)
> oh yeah, are you sure forward slashes are ok in the filename?
>
> - Edwin
>
> ----- Original Message -----
> From: Jo�o Carlos Costa <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
> Sent: Thursday, May 27, 1999 8:33 AM
> Subject: Download ANY binary file
>
>
> > Hi
> >
> > I am trying to write a servlet that allows users to download ANY
> > binary file from a web-server. The servlet must operate on either NN
> > and IE environments.
> > When I invoke the servlet 'Down' (the code goes within this message.
> > The file for download in this example is 'winzip70.exe') off-line
> >
> > http://127.0.0.1:8000/servlet/Down
> >
> > and click the submit button I get a 'File Download' window informing
> > that I want to download the file 'Down72d063a0' from 127.0.0.1.
> > I click 'ok' and a 'Save As' window appears.
> > I choose where I want to put the file (always referred as
> > 'Down72d063a0' and '.Document' type) and click 'Save'.
> > An 'Error' window appears informing 'Cannot copy Down72d063a0:
cannot
> > find the specified file. Make sure you specify the correct path and
> > filename'. I click 'ok'.
> > An 'Information' window appears informing 'Download complete'.
> >
> > I have some questions:
> > why is the download not working?
> > why is 'winzip70.exe' referred as 'Down72d063a0'?
> > In the 'Save As' window, why is the file referred as '.Document'
type?
> >
> > Code of 'Down':
> >
> > import java.io.*;
> > import javax.servlet.*;
> > import javax.servlet.http.*;
> >
> > import com.oreilly.servlet.ServletUtils;
> >
> > public class Down extends HttpServlet {
> > String ACTION="action";
> > String ACTION_SUBMIT="submit";
> > String myfilename="ficheiro";
> >
> > public void init(ServletConfig config) throws ServletException{
> > super.init(config);
> > }
> >
> > public void service(HttpServletRequest req, HttpServletResponse
res)
> > throws ServletException, IOException{
> > res.setContentType("application/octet-stream");
> >
> >
>
res.setHeader("Content-Disposition","attachment;filename="+getParameter(req,
> myfilename));
> > ServletOutputStream out=res.getOutputStream();
> >
> > String uri=req.getRequestURI();
> > String action=getParameter(req,ACTION);
> >
> > try{
> > if((action!=null) && (action.equals(ACTION_SUBMIT))){
> > try{
> > ServletUtils.returnFile(myfilename,out);
> > }
> > catch(FileNotFoundException fnfe){}
> > }
> > else
> > createMain(out,uri);
> > }
> > catch(Exception e){}
> >
> > out.flush();
> > out.close();
> > }
> >
> > private String getParameter(HttpServletRequest req, String param){
> > String values[]=req.getParameterValues(param);
> >
> > if(values!=null)
> > param=values[0];
> >
> > return param;
> > }
> >
> > public void createMain(ServletOutputStream out, String uri) throws
> > IOException{
> > out.println("<html>");
> > out.println("<HEAD>");
> > out.println("<script language='JavaScript'>");
> > out.println("<!-- Begin");
> > out.println("// End -->");
> > out.println("</script>");
> > out.println("</HEAD>");
> > out.println("<body bgcolor='#FDF9F1'>");
> > out.println("<form method=POST action=\""+uri+"\">");
> > out.println("<center><table border='0' width='700'>");
> > out.println("<tr><td> </td></tr>");
> > out.println("<tr>");
> > out.println("<td><input type=hidden
name="+myfilename+"
> > value='c:/temp/winzip70.exe'></td>");
> > out.println("</tr>");
> > out.println("<tr>");
> > out.println("<td><input type=submit name="+ACTION+"
> > value=\""+ACTION_SUBMIT+"\"></td>");
> > out.println("</tr>");
> > out.println("</table></center>");
> > out.println("</form>");
> > out.println("</body>");
> > out.println("</html>");
> >
> > out.flush();
> > out.close();
> > }
> >
> > public void destroy(){
> > super.destroy();
> > }
> > }
> >
> >
> > I thank you all in advance
> >
> > ===
> > Joao Carlos Costa
> >
> >
> >
> >
> >
> >
> >
> > _________________________________________________________
> > DO YOU YAHOO!?
> > Get your free @yahoo.com address at http://mail.yahoo.com
> >
> > ------------------------------------------------------------
> > To unsubscribe, send email to
[EMAIL PROTECTED]
> > and include in the body of the message "unsubscribe
jrun-development".
> >
>
> ------------------------------------------------------------
> To unsubscribe, send email to
[EMAIL PROTECTED]
> and include in the body of the message "unsubscribe
jrun-development".
>
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
___________________________________________________________________________
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