• Post Reply Bookmark Topic Watch Topic
  • New Topic

xml file display in dowload from servlet

 
kamesh aru
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am using xml file in the hyperlink to be displayed and zip file for download i am able download zip file but the xml file giving error

-----------------------------------------------------
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


------------------------------------------------------

The system cannot locate the object specified.

------------------------------------------------------


String filename= req.getParameter("filename");
File testfile =new File(filename);
FileInputStream in = new FileInputStream(new File(testfile));
String contentType;
if(filename.endsWith("zip"))
contentType = "application/x-zip";
else
contentType = "application/xml-external-parsed-entity";
resp.setContentType(contentType);
resp.setHeader("Content-Disposition",
" inline; filename=" + filename);
ServletOutputStream out = resp.getOutputStream();
byte[] buffer = new byte[4 * 1024];
int data;
while((data = in.read(buffer)) != -1){
out.write(buffer, 0, data);
}
out.flush();
out.close();
in.close();

thanks in advance
 
kamesh aru
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have changed the path of xsl in the xml file its working now
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!