1 22 package org.jboss.test.bench.servlet; 23 24 import java.util.Hashtable ; 25 import java.util.Enumeration ; 26 27 import javax.servlet.ServletException ; 28 29 import javax.servlet.http.HttpServlet ; 30 import javax.servlet.http.HttpServletRequest ; 31 import javax.servlet.http.HttpServletResponse ; 32 import javax.servlet.http.HttpSession ; 33 34 public class Dispatcher extends HttpServlet { 35 36 static org.jboss.logging.Logger log = 37 org.jboss.logging.Logger.getLogger(Dispatcher.class); 38 39 public static String [] params = {"hw", "os", "ram", "cpu", "jdk", "ejb", "web", "servlet" }; 40 41 protected void doGet(HttpServletRequest req, HttpServletResponse resp) 42 throws ServletException , java.io.IOException { 43 try { 44 45 resp.setHeader("Location", req.getContextPath() + "/"); 46 47 if (req.getParameter("gototest") != null) 48 saveInfo(req, resp); 50 51 else if (req.getParameter("goejb") != null) 52 testEjb(req, resp); 54 55 else if (req.getParameter("goall") != null) 56 testAll(req, resp); 58 59 else 60 req.getRequestDispatcher("/index.jsp").include(req, resp); 62 } catch (Throwable t) { 63 log.debug("failed", t); 64 } 65 66 } 67 68 71 void saveInfo(HttpServletRequest req, HttpServletResponse resp) 72 throws ServletException , java.io.IOException { 73 74 HttpSession session = req.getSession(); 75 ConfigData conf = (ConfigData)session.getAttribute("conf"); 76 77 for (int i=0; i<conf.size(); i++) { 78 conf.setInfo(conf.getName(i), req.getParameter(conf.getName(i))); 79 } 80 81 req.getRequestDispatcher("/tests.jsp").include(req, resp); 82 83 } 84 85 void testEjb(HttpServletRequest req, HttpServletResponse resp) 86 throws ServletException , java.io.IOException { 87 88 EJBTester ejbTester = new EJBTester(req); 89 90 ejbTester.test(); 92 93 req.setAttribute("ejbTester", ejbTester); 94 95 97 req.getRequestDispatcher("/ejbResult.jsp").include(req, resp); 98 99 } 100 101 void testAll(HttpServletRequest req, HttpServletResponse resp) 102 throws ServletException , java.io.IOException { 103 104 FullTester fullTester = new FullTester(req); 105 106 fullTester.test(); 108 109 req.setAttribute("fullTester", fullTester); 110 111 req.getRequestDispatcher("/allResult.jsp").include(req, resp); 113 114 } 115 116 } 117 118 119 | Popular Tags |