• Post Reply Bookmark Topic Watch Topic
  • New Topic

downloading jar files to client machine

 
amar nath jha
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

When I tried to download jar file present in my lib folder of web-application Instead of downloading it get displayed on the browser.Is there anu setting required for the browser to prevent this.Here is my servlet code.

//code segment
response.setContentType("text/html");
OutputStream out = response.getOutputStream();
byte[] info =null;
InputStream is = getServletContext().getResourceAsStream("/WEB-INF/lib/JarFileDownload.java");
info = new byte[is.available()];
int i=0;
while((i=is.read(info)) != -1)
{
out.write(info,0,i);
}
out.flush();
is.close();
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You told the browser you were sending an HTML file.


Try changing it to:
"application/java-archive"
[ April 25, 2007: Message edited by: Ben Souther ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!