What is wrong with the folowing code ?
The name of the file in htm always gets 'servletname'.html
I also tried to change inline to attachment but that dont solves the problem
------------------- code snippet --------
public void fileKlaarmaken(java.io.File file, int
outputformaat,HttpServletResponse res) throws ServletException,
IOException, FileNotFoundException
{
String fileName = file.getName();
ServletOutputStream out = res.getOutputStream();
if(outputformaat ==
be.vlaanderen.dov.prnlib.Renderer.RENDERER_HTML)
res.setContentType( "text/html" );
else
res.setContentType( "application/pdf" );
res.setContentLength((int) file.length());
res.setHeader("Content-Disposition","inline; filename="+fileName);
returnFile(file, out);
}
public static void returnFile(java.io.File file, OutputStream out) throws
FileNotFoundException, IOException
{
// A FileInputStream is for bytes
FileInputStream fis = null;
BufferedInputStream buffered = null;
try {
fis = new FileInputStream(file);
buffered = new BufferedInputStream(fis);
byte[] buf = new byte[4 * 1024]; // 4K buffer
int bytesRead;
while ((bytesRead = buffered.read(buf)) != -1)
//while ((bytesRead = fis.read(buf)) != -1)
{
out.write(buf, 0, bytesRead);
}
}
finally {
if (fis != null) fis.close();
if (buffered != null) buffered.close();
}
}
public static void returnFile(java.io.File file,
OutputStream out) throws FileNotFoundException, IOException
{
// A FileInputStream is for bytes
FileInputStream fis = null;
BufferedInputStream buffered = null;
try {
fis = new FileInputStream(file);
buffered = new BufferedInputStream(fis);
byte[] buf = new byte[4 * 1024]; // 4K buffer
int bytesRead;
while ((bytesRead = buffered.read(buf)) != -1)
//while ((bytesRead = fis.read(buf)) != -1)
{
out.write(buf, 0, bytesRead);
}
}
finally {
if (fis != null) fis.close();
if (buffered != null) buffered.close();
}
}
------------------- code snippet --------
The name of the file in htm always gets 'servletname'.html
I also tried to change inline to attachment but that dont solves the problem
------------------- code snippet --------
public void fileKlaarmaken(java.io.File file, int
outputformaat,HttpServletResponse res) throws ServletException,
IOException, FileNotFoundException
{
String fileName = file.getName();
ServletOutputStream out = res.getOutputStream();
if(outputformaat ==
be.vlaanderen.dov.prnlib.Renderer.RENDERER_HTML)
res.setContentType( "text/html" );
else
res.setContentType( "application/pdf" );
res.setContentLength((int) file.length());
res.setHeader("Content-Disposition","inline; filename="+fileName);
returnFile(file, out);
}
public static void returnFile(java.io.File file, OutputStream out) throws
FileNotFoundException, IOException
{
// A FileInputStream is for bytes
FileInputStream fis = null;
BufferedInputStream buffered = null;
try {
fis = new FileInputStream(file);
buffered = new BufferedInputStream(fis);
byte[] buf = new byte[4 * 1024]; // 4K buffer
int bytesRead;
while ((bytesRead = buffered.read(buf)) != -1)
//while ((bytesRead = fis.read(buf)) != -1)
{
out.write(buf, 0, bytesRead);
}
}
finally {
if (fis != null) fis.close();
if (buffered != null) buffered.close();
}
}
public static void returnFile(java.io.File file,
OutputStream out) throws FileNotFoundException, IOException
{
// A FileInputStream is for bytes
FileInputStream fis = null;
BufferedInputStream buffered = null;
try {
fis = new FileInputStream(file);
buffered = new BufferedInputStream(fis);
byte[] buf = new byte[4 * 1024]; // 4K buffer
int bytesRead;
while ((bytesRead = buffered.read(buf)) != -1)
//while ((bytesRead = fis.read(buf)) != -1)
{
out.write(buf, 0, bytesRead);
}
}
finally {
if (fis != null) fis.close();
if (buffered != null) buffered.close();
}
}
------------------- code snippet --------