View Javadoc
1 /* 2 * ManagerServlet.java 3 * 4 * Created on February 18, 2003, 8:22 PM 5 */ 6 7 package com.mlw.fps.model.manager; 8 9 import java.io.File; 10 11 import javax.servlet.ServletConfig; 12 import javax.servlet.ServletException; 13 import javax.servlet.http.HttpServlet; 14 import javax.servlet.http.HttpServletRequest; 15 import javax.servlet.http.HttpServletResponse; 16 17 /*** 18 * 19 * @author Matthew Wilson 20 * @version 21 */ 22 public class ManagerServlet extends HttpServlet 23 { 24 25 /*** Initializes the servlet. 26 */ 27 public void init(ServletConfig config) throws ServletException 28 { 29 super.init(config); 30 31 if( !ManagerFactory.isInitialized() ) try 32 { 33 String file = null; 34 if((file = config.getInitParameter("file")) != null) 35 { 36 StringBuffer sb = new StringBuffer() 37 .append(config.getServletContext().getRealPath("WEB-INF")) 38 .append(File.separatorChar).append( file ); 39 40 ManagerFactory.setConfig(sb.toString()); 41 ManagerFactory.init(); 42 } 43 } 44 catch(Exception e) 45 { 46 throw new ServletException(e); 47 } 48 49 } 50 51 /*** Destroys the servlet. 52 */ 53 public void destroy() 54 { 55 56 } 57 58 /*** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. 59 * @param request servlet request 60 * @param response servlet response 61 */ 62 protected void processRequest(HttpServletRequest request, HttpServletResponse response) 63 throws ServletException, java.io.IOException 64 { 65 response.setContentType("text/html"); 66 java.io.PrintWriter out = response.getWriter(); 67 /* output your page here 68 out.println("<html>"); 69 out.println("<head>"); 70 out.println("<title>Servlet</title>"); 71 out.println("</head>"); 72 out.println("<body>"); 73 74 out.println("</body>"); 75 out.println("</html>"); 76 */ 77 out.close(); 78 } 79 80 /*** Handles the HTTP <code>GET</code> method. 81 * @param request servlet request 82 * @param response servlet response 83 */ 84 protected void doGet(HttpServletRequest request, HttpServletResponse response) 85 throws ServletException, java.io.IOException 86 { 87 processRequest(request, response); 88 } 89 90 /*** Handles the HTTP <code>POST</code> method. 91 * @param request servlet request 92 * @param response servlet response 93 */ 94 protected void doPost(HttpServletRequest request, HttpServletResponse response) 95 throws ServletException, java.io.IOException 96 { 97 processRequest(request, response); 98 } 99 100 /*** Returns a short description of the servlet. 101 */ 102 public String getServletInfo() 103 { 104 return "Short description"; 105 } 106 107 }

This page was automatically generated by Maven