A
anilkumar05
I am trying to write a JSP, using which user can download an xml
document..
the following is the code iam using..but in the output at the end od
document it is displaying a question mark, because of which it is
blowing up when i try to open the downloaded xml document..
please help me to remove the extra question mark at the end of
document..
<%@ page import="java.util.*,
java.io.*"
%>
<%@ page language="java"
session="false"
%>
<%
String fpath=request.getParameter("filePath");
//read the file name.
File fFile = new File (fpath);
int i=fpath.lastIndexOf("\\");
String stFileName;
if(i>0)
{
stFileName = fpath.substring(i+1);
}
else
stFileName = fpath;
response.setContentType( "text/xml" );
response.setHeader ("Content-Disposition",
"attachment;filename=\""+stFileName+"\"");
InputStream isStream = null;
BufferedInputStream in = new BufferedInputStream(new
FileInputStream(fFile));
//ServletOutputStream outs = response.getOutputStream();
int bit = 256;
try {
while ((bit) >= 0) {
bit = in.read();
out.write(bit);
}
} catch (IOException ioe) {
ioe.printStackTrace(System.out);
}
out.flush();
out.close();
in.close();
response.flushBuffer();
%>
-----output----
<?xml version="1.0" encoding="iso-8859-1"?>
<tcdt_input>
<parameter name='1'>
<value>t</value>
<value>t</value>
<value>tt</value>
</parameter>
<parameter name='2'>
<value>t</value>
<value>t</value>
<value>t</value>
</parameter>
</tcdt_input>
?
document..
the following is the code iam using..but in the output at the end od
document it is displaying a question mark, because of which it is
blowing up when i try to open the downloaded xml document..
please help me to remove the extra question mark at the end of
document..
<%@ page import="java.util.*,
java.io.*"
%>
<%@ page language="java"
session="false"
%>
<%
String fpath=request.getParameter("filePath");
//read the file name.
File fFile = new File (fpath);
int i=fpath.lastIndexOf("\\");
String stFileName;
if(i>0)
{
stFileName = fpath.substring(i+1);
}
else
stFileName = fpath;
response.setContentType( "text/xml" );
response.setHeader ("Content-Disposition",
"attachment;filename=\""+stFileName+"\"");
InputStream isStream = null;
BufferedInputStream in = new BufferedInputStream(new
FileInputStream(fFile));
//ServletOutputStream outs = response.getOutputStream();
int bit = 256;
try {
while ((bit) >= 0) {
bit = in.read();
out.write(bit);
}
} catch (IOException ioe) {
ioe.printStackTrace(System.out);
}
out.flush();
out.close();
in.close();
response.flushBuffer();
%>
-----output----
<?xml version="1.0" encoding="iso-8859-1"?>
<tcdt_input>
<parameter name='1'>
<value>t</value>
<value>t</value>
<value>tt</value>
</parameter>
<parameter name='2'>
<value>t</value>
<value>t</value>
<value>t</value>
</parameter>
</tcdt_input>
?