我正在尝试重定向到成功的jsp页面,同时从我的servlet返回附件响应(下载XML文件):
这是我的servlet代码:
try {
String file = "File-"+year;
JAXBContext jaxbContext = JAXBContext.newInstance(MyClass.class);
response.setContentType("text/xml; charset=UTF-8");
OutputStream outStream = response.getOutputStream();
javax.xml.bind.Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, new Boolean(true));
jaxbMarshaller.marshal(myobject, outStream);
response.setHeader("Content-Disposition", "attachment; filename="+file+".xml");
// response.sendRedirect("successp.jsp");
} catch (JAXBException e) {
e.printStackTrace();
}