FileDocCategorySizeDatePackage
ListBooksServlet.javaAPI DocExample3930Sat Jun 03 18:32:44 BST 2000com.techbooks

ListBooksServlet

public class ListBooksServlet extends HttpServlet

Fields Summary
private static final String
hostname
Host to connect to for books list
private static final int
portNumber
Port number to connect to for books list
private static final String
file
File to request (URI path) for books list
private static final String
stylesheet
Stylesheet to apply to XML
Constructors Summary
Methods Summary
public voidservice(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)

        //"/home/client/java/newinstance/www/javaxml/techbooks/XSL/computerBooks.xsl";

          
                       
            
        res.setContentType("text/html");            
        
        // Connect and get XML listing of books
        //URL getBooksURL = new URL("http", hostname, portNumber, file);
        URL getBooksURL = new URL("http://newInstance.com/cgi/supplyBooks.pl");
        InputStream in = getBooksURL.openStream();

        try {            
            XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
            
            // Transform XML with XSL stylesheet
            processor.process(new XSLTInputSource(in),
                              new XSLTInputSource(new FileInputStream(stylesheet)),
                              new XSLTResultTarget(res.getOutputStream()));
            
        } catch (Exception e) {
            PrintWriter out = res.getWriter();            
            out.println("Error: " + e.getMessage());
            out.close();
        }