1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
/**
* Servlet implementation class ShowReportFile
*/
public class ShowReportFile extends HttpServlet {
private static final long serialVersionUID = 1L;
// initialize the Servlet. This code is executed once.
public void init(ServletConfig config) throws ServletException {
super.init(config);
ServletContext context = config.getServletContext();
}
/**
* @see HttpServlet#HttpServlet()
*/
public ShowReportFile() {
super();
// TODO Auto-generated constructor stub
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
responsePage("GET", response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
responsePage("POST", response);
}
private void responsePage (String getOrPost, HttpServletResponse response)
throws ServletException, IOException{
// output an HTML page
response.setContentType("text/html");
String webAppPath = getServletContext().getRealPath( "/WEB-INF/liste/" );
TransformerFactory tFactory = javax.xml.transform.TransformerFactory.newInstance();
// Get the XML input document and the stylesheet, both in the servlet engine document directory
Source xmlSource = new javax.xml.transform.stream.StreamSource(webAppPath+"/AIT_Gestion_OUTILS_PLANNING_ACTION_S17_2008.xml");
Source xslSource = new javax.xml.transform.stream.StreamSource(webAppPath+"/_UpgradeReport_Files/UpgradeReport.xslt");
// Generate the transformer.
Transformer transformer;
response.setContentType("text/html");
PrintWriter out = response.getWriter();
try {
transformer = tFactory.newTransformer(xslSource);
// Perform the transformation, sending the output to the response.
transformer.transform(xmlSource,new StreamResult(out));
} catch (TransformerConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} |
Partager