Exemple #1
0
 public void init() {
   context = getServletContext();
   synchronized (context) {
     pool = (ConnectionPool) context.getAttribute("pool");
     if (pool == null) {
       String driverClassName = context.getInitParameter("driverClassName");
       String url = context.getInitParameter("url");
       String userName = context.getInitParameter("username");
       String password = context.getInitParameter("password");
       try {
         pool = new ConnectionPool(driverClassName, url, userName, password);
       } catch (Exception error) {
         Routines.writeToLog(
             servletName, "Unable to create connection pool : " + error, false, context);
       }
       context.setAttribute("pool", pool);
     }
   }
 }
  public LabeledTextField(boolean isIndentedLabel, String label, String format) {
    super();
    super.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    tag = new JLabel(label);
    if (isIndentedLabel) {
      JPanel tag_panel = new JPanel();
      tag_panel.setLayout(new BoxLayout(tag_panel, BoxLayout.X_AXIS));
      tag_panel.add(Box.createHorizontalStrut(Const.LABEL_INDENTATION));
      tag_panel.add(tag);
      tag_panel.add(Box.createHorizontalGlue());
      tag_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
      super.add(tag_panel);
    } else {
      tag.setAlignmentX(Component.LEFT_ALIGNMENT);
      super.add(tag);
    }

    fld = new ActableTextField();
    tag.setLabelFor(fld);
    fld.setAlignmentX(Component.LEFT_ALIGNMENT);
    super.add(fld);

    // preferred_height = fld.getPreferredSize().height + this.TEXT_HEIGHT;
    if (format != null) {
      int num_col;
      fmt = (DecimalFormat) NumberFormat.getInstance();
      fmt.applyPattern(format);
      num_col = Routines.getAdjNumOfTextColumns(fld, format.length());
      fld.setColumns(num_col);
    } else fmt = null;

    /*  No self DocumentListener by default  */
    self_listener = null;

    // tag.setBorder( BorderFactory.createEtchedBorder() );
    fld.setBorder(BorderFactory.createEtchedBorder());

    if (FONT != null) {
      tag.setFont(FONT);
      fld.setFont(FONT);
    }
  }
Exemple #3
0
 public void doGet(HttpServletRequest request, HttpServletResponse response) {
   response.setContentType("text/html");
   PrintWriter webPageOutput = null;
   try {
     webPageOutput = response.getWriter();
   } catch (IOException error) {
     Routines.writeToLog(servletName, "getWriter error : " + error, false, context);
   }
   HttpSession session = request.getSession();
   session.setAttribute("redirect", request.getRequestURL() + "?" + request.getQueryString());
   Connection database = null;
   try {
     database = pool.getConnection(servletName);
   } catch (SQLException error) {
     Routines.writeToLog(servletName, "Unable to connect to database : " + error, false, context);
   }
   if (Routines.loginCheck(true, request, response, database, context)) {
     return;
   }
   String server = context.getInitParameter("server");
   boolean liveSever = false;
   if (server == null) {
     server = "";
   }
   if (server.equals("live")) {
     response.setHeader("Refresh", "60");
   }
   Routines.WriteHTMLHead(
       "View System Log", // title
       false, // showMenu
       13, // menuHighLight
       false, // seasonsMenu
       false, // weeksMenu
       false, // scores
       false, // standings
       false, // gameCenter
       false, // schedules
       false, // previews
       false, // teamCenter
       false, // draft
       database, // database
       request, // request
       response, // response
       webPageOutput, // webPageOutput
       context); // context
   webPageOutput.println("<CENTER>");
   webPageOutput.println(
       "<IMG SRC=\"../Images/Admin.gif\"" + " WIDTH='125' HEIGHT='115' ALT='Admin'>");
   webPageOutput.println("</CENTER>");
   pool.returnConnection(database);
   webPageOutput.println(Routines.spaceLines(1));
   Routines.tableStart(false, webPageOutput);
   Routines.tableHeader("System Log", 0, webPageOutput);
   Routines.tableDataStart(true, false, false, true, true, 0, 0, "scoresrow", webPageOutput);
   boolean firstLine = true;
   int numOfLines = 0;
   try {
     String file = context.getRealPath("/");
     FileReader logFile = new FileReader(file + "/Data/log.txt");
     BufferedReader logFileBuffer = new BufferedReader(logFile);
     boolean endOfFile = false;
     while (!endOfFile) {
       String logFileText = logFileBuffer.readLine();
       if (logFileText == null) {
         endOfFile = true;
       } else {
         if (firstLine) {
           firstLine = false;
         } else {
           webPageOutput.println(Routines.spaceLines(1));
         }
         numOfLines++;
         webPageOutput.println(logFileText);
       }
     }
     logFileBuffer.close();
   } catch (IOException error) {
     Routines.writeToLog(servletName, "Problem with log file : " + error, false, context);
   }
   Routines.tableDataEnd(false, true, true, webPageOutput);
   Routines.tableEnd(webPageOutput);
   if (numOfLines < 20) {
     webPageOutput.println(Routines.spaceLines(20 - numOfLines));
   }
   Routines.WriteHTMLTail(request, response, webPageOutput);
 }