dcsimg
Problems with downloading a file with a servlet..
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, December 11, 2001 10:46 AM

Hi! I am trying to download a file with help of an servlet..my solution is working fine in my visualAgeServlet engin,and also with Jrun Servlet engin on my developingServer. The problem is that when I try to run this servlet in production it will not work.. Could it be because I am using SSL or are behind a firewall? I have used some different code solutions from this page but now noone seems to work.... Any one who have hade the same problem..?? Some special parmeters that must be set in the respones or in my IIS?? The Code    More>>






Hi!
I am trying to download a file with help of an servlet..my solution is working fine in my visualAgeServlet
engin,and also with Jrun Servlet engin on my developingServer.
The problem is that when I try to run this servlet in production it will not work..




Could it be because I am using SSL or are behind a firewall?
I have used some different code solutions from this page but now noone seems to work....
Any one who have hade the same problem..??
Some special parmeters that must be set in the respones or in my IIS??




The Code

			
ServletOutputStream out = null;
try
{

/** Handles the HTTP GET request. */

String fileName;
String content;
byte[] data;

// Set the filename
fileName = "filenamedemo.txt";

// Dummy content
content = "The content of file goes here";

// Set the content type
response.setContentType("application/download");

response.setContentLength(content.length());
response.setHeader("Content-Disposition", "attachment;filename="" + fileName + """);

// The file content
out = response.getOutputStream();
data = content.getBytes();
out.write(data);
try
{
out.flush();
}
catch(Exception ex)
{

}

   <<Less
About | Sitemap | Contact