/* * */ package xid; import java.io.*; import java.text.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; import xid.*; /** * */ public class Test extends HttpServlet { static private org.apache.log4j.Logger log; static { log = org.apache.log4j.Logger.getLogger (Test.class.getName()); } /** * */ public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { doGet (req, res); } /** * */ public void doGet (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { log.info ("Enter"); Presenter xid = new Presenter (getServletContext ().getRealPath ("/"), "testXid.html"); // TagsData datas = new TagsData (); TextTagData text; // Populate attributes of Test 03. text = new TextTagData (); datas.put ("test03", text); text.setText ("mummy"); text.getAttributes ().appendAttribute ("style", "background: blue;"); text.getAttributes ().appendAttribute ("style", "foreground: red;"); text.getAttributes ().setAttribute ("class", "totoClass"); // Populate attributes of Test 04. text = new TextTagData (); text.getAttributes ().setAttribute ("title", "another title"); datas.put ("test04", text); // Populate attributes of Test 05. text = new TextTagData (); datas.put ("test05", text); text.getAttributes ().appendAttribute ("style", "background: blue;"); text.getAttributes ().appendAttribute ("style", "foreground: red;"); text.getAttributes ().setAttribute ("class", "aClass"); // Populate attributes of Test 06. text = new TextTagData (); text.getAttributes ().appendAttribute ("style", "foreground: red;"); text.getAttributes ().setAttribute ("class", "aClass"); datas.put ("test06", text); // Populate attributes of Test 07. text = new TextTagData (); text.getAttributes ().setAttribute ("width", "50%"); datas.put ("test07", text); // Populate attributes of Test 09. text = new TextTagData (); text.getAttributes ().setAttribute ("class", "xid:nodisplay"); datas.put ("test09", text); StringBuffer html; StringBuffer errorMessage; errorMessage = new StringBuffer (); html = xid.doXid (datas, errorMessage); // Display page. response.setContentType ("text/html"); PrintWriter out = response.getWriter(); out.println (""); out.println ("
"); out.println (""); out.println (errorMessage); out.println (""); out.println ("
" + Presenter.restoreEntities (html) + ""); out.println ("
" + Presenter.restoreEntities (html) + ""); } out.println (""); out.println (""); log.info ("Exit"); } /* * */ static public String extractBody (StringBuffer data) { String result = null; // Extraire le contenu du body. String dataLowerCase = data.toString ().toLowerCase (); int startBody = dataLowerCase.indexOf ("") + 6; int endBody = dataLowerCase.indexOf (""); // Note: as failed search is improbable, no care about complexity // in failed search case. if ((startBody == -1) || (endBody == -1)) { result = null; } else { result = data.substring (startBody, endBody).trim (); } // return (result); } } // ////////////////////////////////////////////////////////////////////////