1 27 28 import java.io.*; 29 import java.util.*; 30 import javax.servlet.*; 31 import javax.servlet.http.*; 32 import javax.management.*; 33 34 import com.adventnet.html.dynamic.*; 35 import com.adventnet.adaptors.html.*; 36 37 import com.adventnet.agent.logging.*; 38 39 44 45 public class Jmx_dynamic extends HttpServlet 46 { 47 48 private DynamicMain main; 49 50 private com.adventnet.agent.logging.Log log; 51 52 56 57 public void init(ServletConfig config) throws ServletException 58 { 59 super.init(config); 60 61 try { 62 log = LogFactory.getInstance("HTML"); 63 } 64 catch (InstantiationException ie) 65 { 66 ie.printStackTrace(); 67 } 68 } 69 70 71 78 public void doGet(HttpServletRequest sreq, HttpServletResponse sres) 79 throws ServletException, IOException { 80 sres.setContentType("text/html"); 81 String result = null; 82 sreq.getSession(true); 83 main = new DynamicMain(); 84 85 String name = sreq.getParameter("fname"); 86 if (name != null && name.equals("aboutus.html")) { 87 RequestDispatcher reqDispatch = sreq.getRequestDispatcher("/"+name); 88 reqDispatch.forward(sreq, sres); 89 return; 90 } 91 92 HtmlCreation htmlCr = new HtmlCreation(); 93 try { 94 htmlCr.setContextPath(sreq.getContextPath()); 95 } catch(NoSuchMethodError nsme) { 96 htmlCr.setContextPath(""); 97 } 98 99 main.registerHtmlInterface(htmlCr); 100 main.registerErrorInterface(new DynamicError()); 101 102 Hashtable table = new Hashtable(); 103 104 HttpSession session = sreq.getSession(true); 105 106 String id = session.getId(); 107 109 table.put((String )"Session", session); 110 Enumeration e = sreq.getParameterNames(); 111 112 for (; e.hasMoreElements(); ) { 113 Object paramName = e.nextElement(); 114 String paramValue = sreq.getParameter(paramName.toString()); 115 log.trace("ParamName is "+paramName+" "+"ParamValue is "+paramValue); 116 117 if (paramValue.trim().length() != 0) 118 { 119 table.put(paramName, paramValue); 120 } 121 } 122 123 124 PrintWriter p = sres.getWriter(); 125 126 result = main.processGetRequest(table); 128 129 131 p.println(result); 132 p.flush(); 133 p.close(); 134 return; 135 } 136 137 public void doPost(HttpServletRequest sreq, HttpServletResponse sres) 138 throws ServletException, IOException { 139 sres.setContentType("text/html"); 140 String result = null; 141 143 145 main = new DynamicMain(); 147 148 HtmlCreation htmlCr = new HtmlCreation(); 149 try { 150 htmlCr.setContextPath(sreq.getContextPath()); 151 } catch(NoSuchMethodError nsme) { 152 htmlCr.setContextPath(""); 153 } 154 155 main.registerHtmlInterface(htmlCr); 156 main.registerErrorInterface(new DynamicError()); 157 158 HttpSession session = sreq.getSession(true); 159 160 String objName = sreq.getParameter("attrbName"); 161 Hashtable table = new Hashtable(); 162 table.put((String )"Session", session); 163 164 168 169 171 172 Enumeration e = sreq.getParameterNames(); 173 174 for (; e.hasMoreElements(); ) { 175 Object paramName = e.nextElement(); 176 String paramValue = sreq.getParameter(paramName.toString()); 177 log.trace("ParamName is "+paramName+" "+"ParamValue is "+paramValue); 178 if (paramValue.trim().length() != 0) 179 { 180 table.put(paramName, paramValue); 181 } 182 } 183 if( (Object ) table != null) 185 { 186 PrintWriter p = sres.getWriter(); 187 188 result = main.processPostRequest(table); 189 190 p.println(result); 191 p.flush(); 192 p.close(); 193 }; 194 197 return ; 198 199 200 201 } 203 } 204 | Popular Tags |