/******************************************************************** * Copyright (c) 1999 TECFA. * All Rights Reserved. * * (with a lot taken from The Bean Factory, LLC) * *******************************************************************/ import org.apache.xerces.parsers.DOMParser; import org.xml.sax.*; import org.w3c.dom.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; /******************************************************************** FicheServlet2 affiche un document XML dans une table au format HTML. Le Servlet crée un document à partir d'un document XML et renvoi l'information qu'il contient en HTML après l'avoir parcouru. @version : 1.0 @author : S.M.M & D.K.S ********************************************************************/ public class FicheServlet2 extends HttpServlet { //CONSTANTES public static final String URL = "http://tecfa.unige.ch/guides/java/staf2x/ex/xml/fiches/Fiches2.xml"; public static final String ROOT_ELEMENT_TAG = "Entry"; String[] TheItemNames = { "Title", "Creator", "Description", "Keywords", "Location", "MetaDocumentAuthor", "MainType", "SubType", "Topic", "SubTopic" }; //DONNES protected Document TheDocument; /** Lorsque cette méthode recoit une rèquete du Navigateur, elle renvoi un document XML sous format d'une table. @param req demande http du servlet @param res reponse http du servlet @exception ServletException @exception IOException */ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = new PrintWriter(res.getOutputStream()); out.print(""); out.print("
http://tecfa.unige.ch/guides/java/staf2x/ex/xml/fiches/Fiches2.xml