1 16 19 20 import java.io.IOException ; 21 import java.io.PrintWriter ; 22 23 import java.net.URL ; 24 25 import javax.servlet.ServletException ; 26 import javax.servlet.http.HttpServlet ; 27 import javax.servlet.http.HttpServletRequest ; 28 import javax.servlet.http.HttpServletResponse ; 29 30 import org.apache.xalan.xsltc.compiler.XSLTC; 31 32 36 public class CompileServlet extends HttpServlet { 37 38 44 public void doGet(HttpServletRequest request, 45 HttpServletResponse response) 46 throws IOException , ServletException { 47 48 response.setContentType("text/html"); 49 PrintWriter out = response.getWriter(); 50 51 String stylesheetName = request.getParameter("sheet"); 52 53 out.println("<html><head>"); 54 out.println("<title>Servlet Stylesheet Compilation</title>"); 55 out.println("</head><body>"); 56 57 if (stylesheetName == null) { 58 out.println("<h1>Compilation error</h1>"); 59 out.println("The parameter <b><tt>sheet</tt></b> "+ 60 "must be specified"); 61 } 62 else { 63 XSLTC xsltc = new XSLTC(); 64 65 xsltc.init(); 66 xsltc.compile(new URL (stylesheetName)); 67 out.println("<h1>Compilation successful</h1>"); 68 out.println("The stylesheet was compiled into the translet "+ 69 "class "+xsltc.getClassName() + " and is now "+ 70 "available for transformations on this server."); 71 } 72 out.println("</body></html>"); 73 } 74 } 75 | Popular Tags |