first i compile the ShowHeadersServlet class and put it to the
then i start the tomcat server.
then go to browser and type this.
http://localhost:8080/hellow/A it downloading some file named A. But it is not a file which i need.
Actually downloaded file name is equal to the last name of the URl which i typed in browser.
i need to download the bootstrap.jar file.
Also I put this jar to the bin director in tomcat.
What is wrong with this code ?
no, i don't need a hiperlink in the broser.
I need to download the file when i put the relavant URl in browser.
The problem is that it download the file which is not expected and the name of the file is last name of URL.
First of all I didn't say that you need a hyperlink. You need to set the content-disposition header in the servlet whose code you just showed. Also where is your jar file actually located?? You are using only the jar name in the File class constructor. You should try to use the inbuilt mechanism in servlets like getResourceAsStream to read files from web application's directory. Read this thread or a tutorial like this for more info...
In a web app, relative paths (like "bootstrap.jar") don't work, because there is no notion of a default directory. You need to use an absolute path - the "ServletContext.getRealPath" method will be helpful for that.
Ping & DNS - updated with new look and Ping home screen widget