[Resolvido] Erro - description The requested resource (/file/envio) is not available

Galera estou com um codigo que me da a opcao de download.

O codigo esta blz, mas esta ocorrendo este erro direto description The requested resource (/file/envio) is not available.

Estou usando tomcat 6, netbeans 6

Trecho do codigo(envio.html):

..
    <center><h1> Arquivo para teste -  PDF </h1></center>
        <hr><hr>
       <a href="envio?filename=arquivo1.pdf&pathname=c:/tmp/">
            Download: Arquivo
        </a>
..

Java. (processa.java)

..
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class processa extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        String filename = request.getParameter("filename");
        String pathname = request.getParameter("pathname");

        ServletOutputStream out = response.getOutputStream();
        File file = new File(pathname + filename);
        FileInputStream in = new FileInputStream(file);

        String mime = "application/octet-stream";
        String testname = filename.toUpperCase();
        if(testname.endsWith(".JPEG")) 
            mime = "image/jpeg";
         else if(testname.endsWith(".JPG")) 
            mime = "image/jpg";
         else if(testname.endsWith(".PDF")) 
            mime = "application/pdf";
         else if(testname.endsWith(".ZIP")) 
            mime = "application/zip";
         else if(testname.endsWith(".MPG")) 
            mime = "video/mpeg";
         else if(testname.endsWith(".txt")) 
            mime = "application/txt";
         else if(testname.endsWith(".GIF")) 
            mime = "image/gif";
        
        response.setContentType(mime);
        response.addHeader("content-disposition",
                "attachment; filename=" + filename);
        response.setContentLength((int)file.length());

        int octet;
        while ((octet = in.read()) != -1) 
            out.write(octet);
        
        in.close();
        out.close();
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);

    }
}
..

Alguem sabe o que pode ser?

Oi…

Veja o seu web.xml

caso nao tenha, acrescenta isso:


<servlet>
        <servlet-name>processa</servlet-name>
        <servlet-class>processa</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>processa</servlet-name>
    <url-pattern>/envio</url-pattern>
    </servlet-mapping>

abs

Tatiana

Muito obrigado Tatiana,

Era isso mesmo que estava faltando (distração minha) :confused:

abração