download not work

this download program is not work

pls help me

package servlets;

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

public class FileDloadServlet extends HttpServlet

{

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, java.io.IOException

{

String parentDirectory = getInitParameter("download_directory");

String file = request.getParameter("file");

if (file != null)

{

File f = new File(file);

if (f.isDirectory())

{

//Do something that identifies the file as a directory...

} else

{

//otherwise, open a stram, and begin the download...

InputStream input = new FileInputStream(f);

response.setContentType("application/octet-stream");

response.setBufferSize(8192);

response.setHeader("Content-Disposition","attachment; filename=\"" + f.getName() + "\"");

OutputStream output = response.getOutputStream();

int count = -1;

byte[] buffer = new byte[8192];

while((count=input.read(buffer))!= -1)

{

output.write(buffer, 0, count-1);

}

output.close();

input.close();

}

}

}

}

web.xml

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<servlet>

<servlet-name>FileDloadServlet</servlet-name>

<servlet-class>servlets.FileDloadServlet</servlet-class>

<init-param>

<param-name>download_directory</param-name>

<param-value>C:\Documents and Settings\bbicer\Netbeans\FileUploadJsp\web\Gelen</param-value>

</init-param>

<init-param>

<param-name>FileDloadServlet</param-name>

<param-value>DownloadServlet/FileDloadServlet</param-value>

</init-param>

</servlet>

<session-config>

<session-timeout>

30

</session-timeout>

</session-config>

</web-app>

ilk.html

<html>

<head>

<title></title>

</head>

<body>

<form name="frm" method="get" action="FileDloadServlet.java" >

<a href="FileDloadServlet?file=C:/Documents and Settings/bbicer/Netbeans/FileUploadJsp/web/Gelen/Kis.JPEG">Download</a>

</form>

</body>

</html>

[2681 byte] By [devellopa] at [2007-10-3 0:19:31]
# 1
try output.write(buffer, 0, count);without -1
sergey35a at 2007-7-14 17:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
thank you so much reply me okey i am trying what do you think html section is it true or can i change it(<a href="FileDloadServlet?file=C:/Documents and Settings/bbicer/Netbeans/FileUploadJsp/web/Gelen/Kis.JPEG">Download</a>)can you advise me
devellopa at 2007-7-14 17:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
<html><head></head><body><a href=" http://HOST:PORT/FileDloadServlet?file=C:/Documents and Settings/bbicer/Netbeans/FileUploadJsp/web/Gelen/Kis.JPEG">Download</a></body></html>
sergey35a at 2007-7-14 17:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

again thank you so much

i apply your advise but again get error

error is :::: HTTP Status 404 - /FileDownload/

--

type Status report

message /FileDownload/

description The requested resource (/FileDownload/) is not available.

HTML PAGE 軸 THAT

<html>

<head>

</head>

<body>

<a href="http://localhost:8084/FileDownload?file=C:/Documents and Settings/Baris B/FileDownload/Gelen/Ben.JPEG">Download</a>

</body>

</html>

PLS HELP

devellopa at 2007-7-14 17:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
<a href=" http://localhost:8084/FileDownload? .. is not oktry <a href=" http://localhost:8084/FileDloadServlet?...>
sergey35a at 2007-7-14 17:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
try after adding following entries in the web.xml<servlet-mapping><servlet-name>FileDloadServlet</servlet-name><url-pattern>/FileDloadServlet</url-pattern></servlet-mapping>
moorthya at 2007-7-14 17:10:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...