public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    try {

      response.setContentType("text/html");
      PrintWriter out = response.getWriter();

      /*String n=request.getParameter("username");
      out.print("Welcome "+n);*/

      String name = request.getParameter("name");
      String dob = request.getParameter("dob");
      String address = request.getParameter("address");
      String email = request.getParameter("email");
      HttpSession session = request.getSession(true);
      String userid = (String) session.getAttribute("theName");
      int AccNo = 0;
      String AccMsg = "";

      DbCommunication db_comm = new DbCommunication();
      AccNo = db_comm.accountCreation(name, dob, address, email, userid);
      // db_comm.accountCreation(name,email);
      AccMsg = "Account created successfully. Account number is:" + AccNo;
      // out.println(AccMsg);

      String redirectURL = "accountCreationPage.jsp";
      response.sendRedirect(redirectURL);
      session.setAttribute("AccCreationalMsgStatus", "set");
      session.setAttribute("AccCreationalMsg", AccMsg);

    } catch (Exception e) {
      System.out.println(e);
    }
  }
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    String amount = request.getParameter("amount");
    String amount2 = request.getParameter("amount2");
    String amount3 = request.getParameter("amount3");
    Integer posotita = Integer.parseInt(amount);
    Integer posotita2 = Integer.parseInt(amount2);
    Integer posotita3 = Integer.parseInt(amount3);

    HttpSession session = request.getSession();

    if (session.isNew()) {
      request.setAttribute("sessionVal", "this is a new session");
    } else {
      request.setAttribute("sessionVal", "Welcome Back!");
    }

    double total = ((posotita * 18.50) + (posotita2 * 6.95) + (posotita3 * 1.29));
    session.setAttribute("totalVal", total);

    request.setAttribute("currency", total);
    request.setAttribute("from", amount);
    request.setAttribute("from2", amount2);
    request.setAttribute("from3", amount3);

    RequestDispatcher view = request.getRequestDispatcher("index.jsp");
    view.forward(request, response);
  }
Beispiel #3
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Session Tracking Example";
    HttpSession session = request.getSession(true);
    String heading;

    Integer accessCount = (Integer) session.getAttribute("accessCount");

    if (accessCount == null) {
      accessCount = new Integer(0);
      heading = "Welcome, Newcomer";
    } else {
      heading = "Welcome Back";
      accessCount = new Integer(accessCount.intValue() + 1);
    }

    session.setAttribute("accessCount", accessCount);
    out.println(
        "<BODY BGCOLOR=\"#FDF5E6\">\n"
            + "<H1 ALIGN=\"CENTER\">"
            + heading
            + "</H1>\n"
            + "<H2>Information on Your Session:</H2>\n"
            + "<TABLE BORDER=1 ALIGN=\"CENTER\">\n"
            + "<TR BGCOLOR=\"#FFAD00\">\n"
            + "  <TH>Info Type<TH>Value\n"
            + "<TR>\n"
            + "  <TD>ID\n"
            + "  <TD>"
            + session.getId()
            + "\n"
            + "<TR>\n"
            + "  <TD>Creation Time\n"
            + "  <TD>"
            + new Date(session.getCreationTime())
            + "\n"
            + "<TR>\n"
            + "  <TD>Time of Last Access\n"
            + "  <TD>"
            + new Date(session.getLastAccessedTime())
            + "\n"
            + "<TR>\n"
            + "  <TD>Number of Previous Accesses\n"
            + "  <TD>"
            + accessCount
            + "\n"
            + "</TR>"
            + "</TABLE>\n");

    // the following two statements show how to retrieve parameters in
    // the request.  The URL format is something like:
    // http://localhost:8080/project2/servlet/ShowSession?myname=Chen%20Li
    String myname = request.getParameter("myname");
    if (myname != null) out.println("Hey " + myname + "<br><br>");

    out.println("</BODY></HTML>");
  }
  public void updateTokens(HttpServletRequest request) {
    /** cannot create sessions if response already committed * */
    HttpSession session = request.getSession(false);

    if (session != null) {
      /** create master token if it does not exist * */
      updateToken(session);

      /** create page specific token * */
      if (isTokenPerPageEnabled()) {
        @SuppressWarnings("unchecked")
        Map<String, String> pageTokens =
            (Map<String, String>) session.getAttribute(CsrfGuard.PAGE_TOKENS_KEY);

        /** first time initialization * */
        if (pageTokens == null) {
          pageTokens = new HashMap<String, String>();
          session.setAttribute(CsrfGuard.PAGE_TOKENS_KEY, pageTokens);
        }

        /** create token if it does not exist * */
        if (isProtectedPageAndMethod(request)) {
          createPageToken(pageTokens, request.getRequestURI());
        }
      }
    }
  }
  private void rotateTokens(HttpServletRequest request) {
    HttpSession session = request.getSession(true);

    /** rotate master token * */
    String tokenFromSession = null;

    try {
      tokenFromSession = RandomGenerator.generateRandomId(getPrng(), getTokenLength());
    } catch (Exception e) {
      throw new RuntimeException(
          String.format("unable to generate the random token - %s", e.getLocalizedMessage()), e);
    }

    session.setAttribute(getSessionKey(), tokenFromSession);

    /** rotate page token * */
    if (isTokenPerPageEnabled()) {
      @SuppressWarnings("unchecked")
      Map<String, String> pageTokens =
          (Map<String, String>) session.getAttribute(CsrfGuard.PAGE_TOKENS_KEY);

      try {
        pageTokens.put(
            request.getRequestURI(), RandomGenerator.generateRandomId(getPrng(), getTokenLength()));
      } catch (Exception e) {
        throw new RuntimeException(
            String.format("unable to generate the random token - %s", e.getLocalizedMessage()), e);
      }
    }
  }
  public static void afterRoot(
      FacesContext context, HttpServletRequest req, HttpServletResponse res) {
    HttpSession session = ((HttpServletRequest) req).getSession(false);

    if (session != null)
      session.setAttribute(ViewHandler.CHARACTER_ENCODING_KEY, res.getCharacterEncoding());
  }
  public static void showSession(HttpServletRequest req, HttpServletResponse res, PrintStream out) {

    // res.setContentType("text/html");

    // Get the current session object, create one if necessary
    HttpSession session = req.getSession();

    // Increment the hit count for this page. The value is saved
    // in this client's session under the name "snoop.count".
    Integer count = (Integer) session.getAttribute("snoop.count");
    if (count == null) {
      count = 1;
    } else count = count + 1;
    session.setAttribute("snoop.count", count);

    out.println(HtmlWriter.getInstance().getHtmlDoctypeAndOpenTag());
    out.println("<HEAD><TITLE>SessionSnoop</TITLE></HEAD>");
    out.println("<BODY><H1>Session Snoop</H1>");

    // Display the hit count for this page
    out.println(
        "You've visited this page " + count + ((!(count.intValue() != 1)) ? " time." : " times."));

    out.println("<P>");

    out.println("<H3>Here is your saved session data:</H3>");
    Enumeration atts = session.getAttributeNames();
    while (atts.hasMoreElements()) {
      String name = (String) atts.nextElement();
      out.println(name + ": " + session.getAttribute(name) + "<BR>");
    }

    out.println("<H3>Here are some vital stats on your session:</H3>");
    out.println("Session id: " + session.getId() + " <I>(keep it secret)</I><BR>");
    out.println("New session: " + session.isNew() + "<BR>");
    out.println("Timeout: " + session.getMaxInactiveInterval());
    out.println("<I>(" + session.getMaxInactiveInterval() / 60 + " minutes)</I><BR>");
    out.println("Creation time: " + session.getCreationTime());
    out.println("<I>(" + new Date(session.getCreationTime()) + ")</I><BR>");
    out.println("Last access time: " + session.getLastAccessedTime());
    out.println("<I>(" + new Date(session.getLastAccessedTime()) + ")</I><BR>");

    out.println(
        "Requested session ID from cookie: " + req.isRequestedSessionIdFromCookie() + "<BR>");
    out.println("Requested session ID from URL: " + req.isRequestedSessionIdFromURL() + "<BR>");
    out.println("Requested session ID valid: " + req.isRequestedSessionIdValid() + "<BR>");

    out.println("<H3>Test URL Rewriting</H3>");
    out.println("Click <A HREF=\"" + res.encodeURL(req.getRequestURI()) + "\">here</A>");
    out.println("to test that session tracking works via URL");
    out.println("rewriting even when cookies aren't supported.");

    out.println("</BODY></HTML>");
  }
 /** Get an unused ID string for storing an object in the session */
 protected String getNewSessionObjectId() {
   HttpSession session = getSession();
   synchronized (session) {
     Integer id = (Integer) getSession().getAttribute(SESSION_KEY_OBJECT_ID);
     if (id == null) {
       id = new Integer(1);
     }
     session.setAttribute(SESSION_KEY_OBJECT_ID, new Integer(id.intValue() + 1));
     return id.toString();
   }
 }
  public void updateToken(HttpSession session) {
    String tokenValue = (String) session.getAttribute(getSessionKey());

    /** Generate a new token and store it in the session. * */
    if (tokenValue == null) {
      try {
        tokenValue = RandomGenerator.generateRandomId(getPrng(), getTokenLength());
      } catch (Exception e) {
        throw new RuntimeException(
            String.format("unable to generate the random token - %s", e.getLocalizedMessage()), e);
      }

      session.setAttribute(getSessionKey(), tokenValue);
    }
  }
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    HttpSession session = request.getSession(false);
    if (session == null) {
      response.sendRedirect("login.html");
      return;
    }

    String userName = (String) session.getAttribute("userName");
    if (isMissing(userName)) {
      response.sendRedirect("login.html");
      return;
    }
    String title = request.getParameter("title");
    String link = request.getParameter("link");
    String description = request.getParameter("description");
    session.setAttribute("title", title);
    session.setAttribute("link", link);
    session.setAttribute("description", description);
    String address = "WEB-INF/view/SaveBookmarkPage.jsp";
    String urlEncoding = response.encodeURL(address);
    RequestDispatcher dispatcher = request.getRequestDispatcher(urlEncoding);
    dispatcher.forward(request, response);
  }
 /** Get the ID with which the object is associated with the session, if any */
 protected String getSessionObjectId(Object obj) {
   HttpSession session = getSession();
   BidiMap map;
   synchronized (session) {
     map = (BidiMap) session.getAttribute(SESSION_KEY_OBJ_MAP);
     if (map == null) {
       map = new DualHashBidiMap();
       session.setAttribute(SESSION_KEY_OBJ_MAP, map);
     }
   }
   synchronized (map) {
     String id = (String) map.get(obj);
     if (id == null) {
       id = getNewSessionObjectId();
       map.put(obj, id);
     }
     return id;
   }
 }
  /**
   * Handles HTTP GET requests.
   *
   * @param request Description of the Parameter
   * @param response Description of the Parameter
   * @exception ServletException if there is a Servlet failure
   * @exception IOException if there is an IO failure
   */
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    HttpSession session = request.getSession();

    Integer sessionCounter = (Integer) session.getAttribute("project4SessionCounter");

    if (sessionCounter == null) {
      Integer newCounter = new Integer(1);
      sessionCounter = newCounter;
    } else {
      sessionCounter++;
    }
    session.setAttribute("project4SessionCounter", sessionCounter);

    String url = "/project4Session.jsp";

    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);

    dispatcher.forward(request, response);
  }
  public boolean convalida() {
    boolean tuttoOk = true;
    Map<String, String> errori = new HashMap<String, String>();

    if ((nome == null) || nome.equals("")) {
      tuttoOk = false;
      request.setAttribute("nome", nome);
      errori.put("nome", "campo obbligatorio");
    }

    if ((descrizione == null) || descrizione.equals("")) {
      tuttoOk = false;
      request.setAttribute("descrizione", descrizione);
      errori.put("descrizione", "campo obbligatorio");
    }

    if ((codice == null) || codice.equals("")) {
      tuttoOk = false;
      request.setAttribute("codice", codice);
      errori.put("codice", "campo obbligatorio");
    }

    if (!isInteger(disponibilita)) {
      tuttoOk = false;
      request.setAttribute("disponibilita", disponibilita);
      errori.put("disponibilita", "formato non valido");
    }

    if (!isInteger(prezzo)) {
      tuttoOk = false;
      request.setAttribute("prezzo", prezzo);
      errori.put("prezzo", "formato non valido");
    }
    if (!tuttoOk) request.setAttribute("errori", errori);
    HttpSession sess = request.getSession();
    sess.setAttribute("errori", errori);
    return tuttoOk;
  }
Beispiel #14
0
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    // Variable initializations.
    HttpSession session = request.getSession();
    FileItem image_file = null;
    int record_id = 0;
    int image_id;

    // Check if a record ID has been entered.
    if (request.getParameter("recordID") == null || request.getParameter("recordID").equals("")) {
      // If no ID has been entered, send message to jsp.
      response_message =
          "<p><font color=FF0000>No Record ID Detected, Please Enter One.</font></p>";
      session.setAttribute("msg", response_message);
      response.sendRedirect("UploadImage.jsp");
    }

    try {
      // Parse the HTTP request to get the image stream.
      DiskFileUpload fu = new DiskFileUpload();
      // Will get multiple image files if that happens and can be accessed through FileItems.
      List<FileItem> FileItems = fu.parseRequest(request);

      // Connect to the database and create a statement.
      conn = getConnected(drivername, dbstring, username, password);
      stmt = conn.createStatement();

      // Process the uploaded items, assuming only 1 image file uploaded.
      Iterator<FileItem> i = FileItems.iterator();

      while (i.hasNext()) {
        FileItem item = (FileItem) i.next();

        // Test if item is a form field and matches recordID.
        if (item.isFormField()) {
          if (item.getFieldName().equals("recordID")) {
            // Covert record id from string to integer.
            record_id = Integer.parseInt(item.getString());

            String sql = "select count(*) from radiology_record where record_id = " + record_id;
            int count = 0;

            try {
              rset = stmt.executeQuery(sql);

              while (rset != null && rset.next()) {
                count = (rset.getInt(1));
              }
            } catch (SQLException e) {
              response_message = e.getMessage();
            }

            // Check if recordID is in the database.
            if (count == 0) {
              // Invalid recordID, send message to jsp.
              response_message =
                  "<p><font color=FF0000>Record ID Does Not Exist In Database.</font></p>";
              session.setAttribute("msg", response_message);
              // Close connection.
              conn.close();
              response.sendRedirect("UploadImage.jsp");
            }
          }
        } else {
          image_file = item;

          if (image_file.getName().equals("")) {
            // No file, send message to jsp.
            response_message = "<p><font color=FF0000>No File Selected For Record ID.</font></p>";
            session.setAttribute("msg", response_message);
            // Close connection.
            conn.close();
            response.sendRedirect("UploadImage.jsp");
          }
        }
      }

      // Get the image stream.
      InputStream instream = image_file.getInputStream();

      BufferedImage full_image = ImageIO.read(instream);
      BufferedImage thumbnail = shrink(full_image, 10);
      BufferedImage regular_image = shrink(full_image, 5);

      // First, to generate a unique img_id using an SQL sequence.
      rset1 = stmt.executeQuery("SELECT image_id_sequence.nextval from dual");
      rset1.next();
      image_id = rset1.getInt(1);

      // Insert an empty blob into the table first. Note that you have to
      // use the Oracle specific function empty_blob() to create an empty blob.
      stmt.execute(
          "INSERT INTO pacs_images VALUES("
              + record_id
              + ","
              + image_id
              + ", empty_blob(), empty_blob(), empty_blob())");

      // to retrieve the lob_locator
      // Note that you must use "FOR UPDATE" in the select statement
      String cmd = "SELECT * FROM pacs_images WHERE image_id = " + image_id + " FOR UPDATE";
      rset = stmt.executeQuery(cmd);
      rset.next();
      BLOB myblobFull = ((OracleResultSet) rset).getBLOB(5);
      BLOB myblobThumb = ((OracleResultSet) rset).getBLOB(3);
      BLOB myblobRegular = ((OracleResultSet) rset).getBLOB(4);

      // Write the full size image to the blob object.
      OutputStream fullOutstream = myblobFull.getBinaryOutputStream();
      ImageIO.write(full_image, "jpg", fullOutstream);
      // Write the thumbnail size image to the blob object.
      OutputStream thumbOutstream = myblobThumb.getBinaryOutputStream();
      ImageIO.write(thumbnail, "jpg", thumbOutstream);
      // Write the regular size image to the blob object.
      OutputStream regularOutstream = myblobRegular.getBinaryOutputStream();
      ImageIO.write(regular_image, "jpg", regularOutstream);

      // Commit the changes to database.
      stmt.executeUpdate("commit");
      response_message = "<p><font color=00CC00>Upload Successful.</font></p>";
      session.setAttribute("msg", response_message);

      instream.close();
      fullOutstream.close();
      thumbOutstream.close();
      regularOutstream.close();

      // Close connection.
      conn.close();
      response.sendRedirect("UploadImage.jsp");

      instream.close();
      fullOutstream.close();
      thumbOutstream.close();
      regularOutstream.close();

      // Close connection.
      conn.close();
    } catch (Exception ex) {
      response_message = ex.getMessage();
    }
  }
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    javax.servlet.jsp.PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html;charset=ISO-8859-1");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n\r\n");
      out.write("\r\n\r\n");

      String strIp = (String) request.getParameter("ip");
      String strCommunityString = (String) request.getParameter("cs");
      String strPort = (String) request.getParameter("port");
      String strTimeout = (String) request.getParameter("timeout");
      String strRetries = (String) request.getParameter("retries");
      String strNodeLabel = (String) request.getParameter("node");
      String strNodeId = request.getParameter("nodeId");
      String strFirstTime = (String) request.getParameter("firsttime");
      String strWindowId = (String) request.getParameter("windowid");

      // Create the querier and make the request.
      QueryFactory factory = new QueryFactory();
      Querier querier = (Querier) factory.createQuerier(WinPagePerfSnmpQuerier.QUERIER_NAME);
      DeviceCommunicator deviceCommunicator = new DeviceCommunicator();
      deviceCommunicator.sendQuery(querier, strIp);

      // Error processing
      if (querier.getErrorStatus() == -1) {
        RequestDispatcher rd =
            getServletContext()
                .getRequestDispatcher("/jsp/WTerror-handler.jsp?error=SnmpCommError");
        rd.forward(request, response);
        return;
      }
      if (querier.getErrorStatus() == -2) {
        RequestDispatcher rd =
            getServletContext()
                .getRequestDispatcher("/jsp/WTerror-handler.jsp?error=NoPerfmibSnmpError");
        rd.forward(request, response);
        return;
      }

      if (querier.getErrorStatus() != 0) {
        RequestDispatcher rd =
            getServletContext().getRequestDispatcher("/jsp/WTerror-handler.jsp?error=SnmpError");
        rd.forward(request, response);
        return;
      }

      Map calcs = querier.getCalculations();
      long[] results = (long[]) calcs.get(WinPagePerfSnmpQuerier.PAGE_RESULTS);

      if (results[0] < 0
          || results[1] < 0
          || results[2] < 0
          || results[3] < 0
          || results[4] < 0
          || results[5] < 0
          || results[6] < 0
          || results[7] < 0
          || results[8] < 0
          || results[9] < 0) {
        RequestDispatcher rd =
            getServletContext().getRequestDispatcher("/jsp/WTerror-handler.jsp?error=SnmpError");
        rd.forward(request, response);
        return;
      }

      Vector vPageStats = null;

      if (strFirstTime == null) {
        // Not the first time, so get the previous polled data from the session
        vPageStats = (Vector) session.getAttribute("vPageStats" + strWindowId);
      } else {
        // This is the first time in this JSP, so create the Vector which will contain the
        // polled data
        Random random = new Random();
        strWindowId = String.valueOf(random.nextInt());

        vPageStats = new Vector();
      }

      vPageStats.add(results);
      session.setAttribute("vPageStats" + strWindowId, vPageStats);

      // This random number is used to prevent the brower from caching the IMG tags
      Random random = new Random();
      int randomInt = random.nextInt();

      out.write("\r\n\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n  ");
      out.write("<title>WebTelemetry - Graphs | Real-Time | Windows Page Performance Monitoring");
      out.write("</title>\r\n  ");
      out.write("<META HTTP-EQUIV=\"refresh\" CONTENT=\"");
      out.print(WTProperties.getMonitorUIRefreshRate());
      out.write("; URL=");
      out.print(WTTools.getJspURL(request));
      out.write("WTwin-page-monitor.jsp?cs=");
      out.print(URLEncoder.encode(strCommunityString, "UTF-8"));
      out.write("&ip=");
      out.print(strIp);
      out.write("&port=");
      out.print(strPort);
      out.write("&timeout=");
      out.print(strTimeout);
      out.write("&retries=");
      out.print(strRetries);
      out.write("&node=");
      out.print(URLEncoder.encode(strNodeLabel, "UTF-8"));
      out.write("&windowid=");
      out.print(strWindowId);
      out.write("&nodeId=");
      out.print(strNodeId);
      out.write("\">\r\n  ");
      out.write(
          "<link rel=\"stylesheet\" type=\"text/css\" href=\"/wt-portal/css/default.css\" />\r\n  ");
      out.write("<script type=\"text/javascript\" src=\"/wt-portal/javascript/WTtools.js\">");
      out.write("</script>\r\n");
      out.write("</head>\r\n");
      out.write("<body>\r\n");
      String title =
          "Graphs - Real-Time - Windows Page Performance Monitoring for Node: " + strNodeLabel;
      out.write("\r\n");
      request.setAttribute("title", title);
      request.setAttribute("nodeJsp", "/wt-monitor/element/node.jsp?node=" + strNodeId);
      out.write("\r\n");
      /* ----  c:import ---- */
      org.apache.taglibs.standard.tag.el.core.ImportTag _jspx_th_c_import_0 =
          (org.apache.taglibs.standard.tag.el.core.ImportTag)
              _jspx_tagPool_c_import_url_context.get(
                  org.apache.taglibs.standard.tag.el.core.ImportTag.class);
      _jspx_th_c_import_0.setPageContext(pageContext);
      _jspx_th_c_import_0.setParent(null);
      _jspx_th_c_import_0.setContext("/wt-monitor");
      _jspx_th_c_import_0.setUrl("/includes/header.jsp");
      int[] _jspx_push_body_count_c_import_0 = new int[] {0};
      try {
        int _jspx_eval_c_import_0 = _jspx_th_c_import_0.doStartTag();
        if (_jspx_eval_c_import_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
          if (_jspx_eval_c_import_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) {
            javax.servlet.jsp.tagext.BodyContent _bc = pageContext.pushBody();
            _jspx_push_body_count_c_import_0[0]++;
            out = _bc;
            _jspx_th_c_import_0.setBodyContent(_bc);
            _jspx_th_c_import_0.doInitBody();
          }
          do {
            out.write("\r\n\t");
            if (_jspx_meth_c_param_0(
                _jspx_th_c_import_0, pageContext, _jspx_push_body_count_c_import_0)) return;
            out.write("\r\n\t");
            if (_jspx_meth_c_param_1(
                _jspx_th_c_import_0, pageContext, _jspx_push_body_count_c_import_0)) return;
            out.write("\r\n\t");
            if (_jspx_meth_c_param_2(
                _jspx_th_c_import_0, pageContext, _jspx_push_body_count_c_import_0)) return;
            out.write("\r\n");
            int evalDoAfterBody = _jspx_th_c_import_0.doAfterBody();
            if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break;
          } while (true);
          if (_jspx_eval_c_import_0 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE)
            out = pageContext.popBody();
          _jspx_push_body_count_c_import_0[0]--;
        }
        if (_jspx_th_c_import_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return;
      } catch (Throwable _jspx_exception) {
        while (_jspx_push_body_count_c_import_0[0]-- > 0) out = pageContext.popBody();
        _jspx_th_c_import_0.doCatch(_jspx_exception);
      } finally {
        _jspx_th_c_import_0.doFinally();
        _jspx_tagPool_c_import_url_context.reuse(_jspx_th_c_import_0);
      }
      out.write("\t\r\n\t");
      out.write("\r\n");
      out.write("<div align=\"center\">\r\n");
      out.write("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n\t");
      out.write("<tr>\r\n\t\t");
      out.write("<td align=\"right\">");
      out.write("<IMG SRC=\"");
      out.print(WTTools.getServletURL(request));
      out.write("WTsnmpRealTimeGraphs?chart=winpagefaultchart&random=");
      out.print(randomInt);
      out.write("&windowid=");
      out.print(strWindowId);
      out.write("\" BORDER=0>");
      out.write("</td>\r\n\t\t");
      out.write("<td>");
      out.write(
          "<img src=\"/wt-portal/images/spacers/spacer.gif\" height=\"1\" width=\"20\" border=\"0\" alt=\"WebTelemetry\">");
      out.write("</td>\r\n\t\t");
      out.write("<td>");
      out.write("<IMG SRC=\"");
      out.print(WTTools.getServletURL(request));
      out.write("WTsnmpRealTimeGraphs?chart=winpagefaultseries&random=");
      out.print(randomInt);
      out.write("&windowid=");
      out.print(strWindowId);
      out.write("\" BORDER=0>");
      out.write("</td>\r\n\t");
      out.write("</tr>\r\n\t");
      out.write("<tr>\r\n\t\t");
      out.write("<td align=\"right\">");
      out.write("<IMG SRC=\"");
      out.print(WTTools.getServletURL(request));
      out.write("WTsnmpRealTimeGraphs?chart=winpagenumchart&random=");
      out.print(randomInt);
      out.write("&windowid=");
      out.print(strWindowId);
      out.write("\" BORDER=0>");
      out.write("</td>\r\n\t\t");
      out.write("<td>&nbsp;");
      out.write("</td>\r\n\t\t");
      out.write("<td>");
      out.write("<IMG SRC=\"");
      out.print(WTTools.getServletURL(request));
      out.write("WTsnmpRealTimeGraphs?chart=winpagenumseries&random=");
      out.print(randomInt);
      out.write("&windowid=");
      out.print(strWindowId);
      out.write("\" BORDER=0>");
      out.write("</td>\r\n\t");
      out.write("</tr>\r\n\t");
      out.write("<tr>\r\n\t\t");
      out.write("<td align=\"right\">");
      out.write("<IMG SRC=\"");
      out.print(WTTools.getServletURL(request));
      out.write("WTsnmpRealTimeGraphs?chart=winpagetimeschart&random=");
      out.print(randomInt);
      out.write("&windowid=");
      out.print(strWindowId);
      out.write("\" BORDER=0>");
      out.write("</td>\r\n\t\t");
      out.write("<td>&nbsp;");
      out.write("</td>\r\n\t\t");
      out.write("<td>");
      out.write("<IMG SRC=\"");
      out.print(WTTools.getServletURL(request));
      out.write("WTsnmpRealTimeGraphs?chart=winpagetimesseries&random=");
      out.print(randomInt);
      out.write("&windowid=");
      out.print(strWindowId);
      out.write("\" BORDER=0>");
      out.write("</td>\r\n\t");
      out.write("</tr>\r\n");
      out.write("</table>\r\n");
      out.write("</div>\r\n");
      out.write("<br>\r\n\r\n");
      /* ----  c:import ---- */
      org.apache.taglibs.standard.tag.el.core.ImportTag _jspx_th_c_import_1 =
          (org.apache.taglibs.standard.tag.el.core.ImportTag)
              _jspx_tagPool_c_import_url_context_nobody.get(
                  org.apache.taglibs.standard.tag.el.core.ImportTag.class);
      _jspx_th_c_import_1.setPageContext(pageContext);
      _jspx_th_c_import_1.setParent(null);
      _jspx_th_c_import_1.setContext("/wt-monitor");
      _jspx_th_c_import_1.setUrl("/includes/footer.jsp");
      int[] _jspx_push_body_count_c_import_1 = new int[] {0};
      try {
        int _jspx_eval_c_import_1 = _jspx_th_c_import_1.doStartTag();
        if (_jspx_th_c_import_1.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) return;
      } catch (Throwable _jspx_exception) {
        while (_jspx_push_body_count_c_import_1[0]-- > 0) out = pageContext.popBody();
        _jspx_th_c_import_1.doCatch(_jspx_exception);
      } finally {
        _jspx_th_c_import_1.doFinally();
        _jspx_tagPool_c_import_url_context_nobody.reuse(_jspx_th_c_import_1);
      }
      out.write("\r\n\t\r\n");
      out.write("</body>\r\n");
      out.write("</html>");
    } catch (Throwable t) {
      out = _jspx_out;
      if (out != null && out.getBufferSize() != 0) out.clearBuffer();
      if (pageContext != null) pageContext.handlePageException(t);
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext);
    }
  }
Beispiel #16
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String email = request.getParameter("email");
    String password = request.getParameter("password");
    String verifypassword = request.getParameter("verifypassword");
    Map<String, String> myResponse = new HashMap<String, String>();
    PrintWriter out = response.getWriter();
    if (email.matches(
        "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
            + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")) // make sure email is properly
    // formatted
    {
      try {

        MongoURI mongoURI = new MongoURI(System.getenv("MONGOHQ_URL"));
        DB db = mongoURI.connectDB(); // instance of databse
        db.authenticate(mongoURI.getUsername(), mongoURI.getPassword()); // authenticates d
        // Set<string> accounts = db.getCollectionName("accounts");
        // Mongo mongo = new Mongo("localhost", 27017); //creates new instance of mongo
        // DB db = mongo.getDB("fourup"); //gets fourup database
        DBCollection accounts = db.getCollection("accounts"); // creates collection for accounts	
        BasicDBObject query = new BasicDBObject(); // creates a basic object named query
        query.put("email", email); // sets email to email
        DBCursor cursor = accounts.find(query);
        if (cursor.size() > 0) // check if email has already been registered
        {
          myResponse.put("Status", "Error");
          myResponse.put("Error", "Account already exists using this email address.");
        } else // since email doesn't currently exist in DB, go ahead and register user
        {
          if (password.equals(
              verifypassword)) // check that both of the passwords entered match each other
          {
            BasicDBObject document = new BasicDBObject();
            int salt = getSalt();
            String hpass = passwrdHash(password, salt);
            document.put("email", email);
            document.put("salt", salt);
            document.put("password", hpass); // this is where we need to hash the password
            accounts.insert(document);
            myResponse.put("Status", "Sucess");
            myResponse.put("Sucess", "Account has been Created");
            AccountObject user = new AccountObject(email, hpass);
            // set session
            HttpSession session = request.getSession();
            session.setAttribute("currentUser", email);
            // return cookie
            Cookie cookie = new Cookie("fourupCookie", email); // add the login information here
            response.addCookie(cookie);
            // redirect to homepage
            String message = "this is a test";
            myResponse.put("html", "<html></html>");
            response.setContentType("application/json");
            response.setStatus(HttpServletResponse.SC_OK);
            // response.sendRedirect("index.html"); //should add check to index page for cookie with
            // login information
          } else {
            myResponse.put("Status", "Failed");
            myResponse.put("Failed", "Passwords do not match.");
          }
        }

      } catch (MongoException e) {

        out.write(e.getMessage());
      }
    } else {
      myResponse.put("Status", "Invalid");
      myResponse.put(
          "Invalid", "The email address has not been entered correctly."); // should output error
    }

    String strResponse = new Gson().toJson(myResponse);
    response.getWriter().write(strResponse);
    response.getWriter().close();
  }
  /**
   * Processes the request coming to the servlet and grabs the attributes set by the servlet and
   * uses them to fire off pre-determined methods set in the setupActionMethods function of the
   * servlet.
   *
   * @param request the http request coming from the browser.
   * @param response the http response going to the browser.
   * @throws javax.servlet.ServletException
   * @throws java.io.IOException
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    if (!actionInitialized) {
      LogController.write(this, "This dispatcher servlet is not initialized properly!");
      return;
    }

    if (actionTag == null) {
      LogController.write(this, "There is no action attribute tag name!");
      return;
    }

    HttpSession httpSession = request.getSession();
    UserSession userSession = (UserSession) httpSession.getAttribute("user_session");

    if (userSession == null) {
      LogController.write(this, "User session is no longer available in this http session.");

      userSession = new UserSession();

      // We always want a user session though...
      httpSession.setAttribute("user_session", userSession);
    }

    String action = (String) request.getAttribute(actionTag);

    try {
      if (action == null) {
        // There is no action attribute specified, check parameters.
        String external_action = (String) request.getParameter(actionTag);

        if (external_action != null) {
          Method method = externalActions.get(external_action);

          if (method != null) {
            LogController.write(this, "Performing external action: " + external_action);
            method.invoke(this, new Object[] {userSession, request, response});
          } else {
            if (defaultExternalMethod != null) {
              LogController.write(this, "Performing default external action.");
              defaultExternalMethod.invoke(this, new Object[] {userSession, request, response});
            } else {
              LogController.write(this, "Unable to perform default external action.");
            }
          }
        } else {
          if (defaultExternalMethod != null) {
            LogController.write(this, "Performing default external action.");
            defaultExternalMethod.invoke(this, new Object[] {userSession, request, response});
          } else {
            LogController.write(this, "Unable to perform default external action.");
          }
        }
      } else {
        Method method = internalActions.get(action);

        if (method != null) {
          LogController.write(this, "Performing internal action: " + action);
          method.invoke(this, new Object[] {userSession, request, response});
        } else {
          if (defaultInternalMethod != null) {
            LogController.write(this, "Performing default internal action.");
            defaultInternalMethod.invoke(this, new Object[] {userSession, request, response});
          } else {
            LogController.write(this, "Unable to perform default internal action.");
          }
        }

        request.removeAttribute("application_action");
      }
    } catch (IllegalAccessException accessEx) {
      LogController.write(this, "Exception while processing request: " + accessEx.getMessage());
    } catch (InvocationTargetException invokeEx) {
      LogController.write(this, "Exception while processing request: " + invokeEx.toString());
      invokeEx.printStackTrace();
    } catch (Exception ex) {
      LogController.write(this, "Unknown exception: " + ex.toString());
    }
  }
  /**
   * Handles HTTP POST requests.
   *
   * @param request Description of the Parameter
   * @param response Description of the Parameter
   * @exception ServletException if there is a Servlet failure
   * @exception IOException if there is an IO failure
   */
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html");
    HttpSession session = request.getSession();

    System.out.println(
        "In Project4AddServlet...get form parms of Employee, set into INSERT sql, return to add.");
    String url = null;

    String firstName = request.getParameter("firstName");
    String lastName = request.getParameter("lastName");
    String ssn = request.getParameter("ssn");
    String department = request.getParameter("department");
    String roomNumber = request.getParameter("roomNumber");
    String phoneNumber = request.getParameter("phoneNumber");

    // These session properties will persist between validations, in the JSP, input tag, text
    // value="${EL item}".
    session.setAttribute("firstName", firstName);
    session.setAttribute("lastName", lastName);
    session.setAttribute("ssn", ssn);
    session.setAttribute("department", department);
    session.setAttribute("roomNumber", roomNumber);
    session.setAttribute("phoneNumber", phoneNumber);

    EmployeeDirectory employeeDirectory =
        (EmployeeDirectory) getServletContext().getAttribute("employeeDirectory");

    // associate the Message with the request, and clear it before forwarding to JSP page
    String AddMessage = "";
    boolean firstNameErr = false;
    boolean lastNameErr = false;
    boolean ssnErr = false;
    boolean departmentErr = false;
    boolean roomNumberErr = false;
    boolean phoneNumberErr = false;

    // Validate that all fields have valid data, prior to employeeDirectory.Add()

    if (firstName == null || firstName.equals("")) {
      AddMessage = "Please enter missing First Name.";
      firstNameErr = true;
    } else if (lastName == null || lastName.equals("")) {
      AddMessage = "Please enter missing Last Name.";
      lastNameErr = true;
    } else if (ssn == null || ssn.equals("")) {
      AddMessage = "Please enter missing SSN.";
      ssnErr = true;
    } else if (department == null || department.equals("")) {
      AddMessage = "Please enter missing Department.";
      departmentErr = true;
    } else if (roomNumber == null || roomNumber.equals("")) {
      AddMessage = "Please enter missing Room Number.";
      roomNumberErr = true;
    } else if (phoneNumber == null || phoneNumber.equals("")) {
      AddMessage = "Please enter missing Phone Number.";
      phoneNumberErr = true;
    } else {
      employeeDirectory.addNewEmployee(
          firstName, lastName, ssn, department, roomNumber, phoneNumber);
      AddMessage = "Employee added.";
    }

    session.setAttribute("project4AddMessage", AddMessage);
    session.setAttribute("project4firstNameErr", firstNameErr);
    session.setAttribute("project4lastNameErr", lastNameErr);
    session.setAttribute("project4ssnErr", ssnErr);
    session.setAttribute("project4departmentErr", departmentErr);
    session.setAttribute("project4roomNumberErr", roomNumberErr);
    session.setAttribute("project4phoneNumberErr", phoneNumberErr);

    url = "/java112/Project4EmployeeAdd.jsp"; // do a redirect using url back to
    // Project4EmployeeAdd.jsp page.
    response.sendRedirect(url);
  }
Beispiel #19
0
  // *****************************************************
  // Process the initial request from Proshop_main
  // *****************************************************
  //
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    //
    //  Prevent caching so sessions are not mangled
    //
    resp.setHeader("Pragma", "no-cache"); // for HTTP 1.0
    resp.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); // for HTTP 1.1
    resp.setDateHeader("Expires", 0); // prevents caching at the proxy server

    resp.setContentType("text/html");
    PrintWriter out = resp.getWriter();

    HttpSession session = SystemUtils.verifyHotel(req, out); // check for intruder

    if (session == null) {

      return;
    }

    String club = (String) session.getAttribute("club"); // get club name
    String user = (String) session.getAttribute("user");

    if (req.getParameter("clubswitch") != null
        && req.getParameter("clubswitch").equals("1")
        && req.getParameter("club") != null) {

      //
      //  Request is to switch clubs - switch the db (TPC or Demo sites)
      //
      String newClub = req.getParameter("club");

      Connection con = null;

      //
      //  release the old connection
      //
      ConnHolder holder = (ConnHolder) session.getAttribute("connect");

      if (holder != null) {

        con = holder.getConn(); // get the connection for previous club
      }

      if (con != null) {
        /*
                   // abandon any unfinished transactions
                   try { con.rollback(); }
                   catch (Exception ignore) {}
        */
        // close/release the connection
        try {
          con.close();
        } catch (Exception ignore) {
        }
      }

      //
      //  Connect to the new club
      //
      try {
        con = dbConn.Connect(newClub); // get connection to this club's db
      } catch (Exception ignore) {
      }

      holder = new ConnHolder(con);

      session.setAttribute("club", newClub);
      session.setAttribute("connect", holder);

      out.println("<HTML><HEAD><Title>Switching Sites</Title>");
      out.println("<meta http-equiv=\"Refresh\" content=\"0; url=/" + rev + "/hotel_home.htm\">");
      out.println("</HEAD>");
      out.println("<BODY><CENTER><BR>");
      out.println("<BR><H2>Switching Sites</H2><BR>");
      out.println("<a href=\"/" + rev + "/hotel_home.htm\" target=_top>Continue</a><br>");
      out.println("</CENTER></BODY></HTML>");
      out.close();
      return;
    }

    //
    //  Call is to display the Home page.
    //
    out.println("<html><head>");
    out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">");
    out.println("<meta http-equiv=\"Content-Language\" content=\"en-us\">");
    out.println("<title> \"ForeTees Hotel Home Page\"</title>");
    out.println(
        "<script language=\"JavaScript\" src=\"/" + rev + "/web utilities/foretees.js\"></script>");

    out.println(
        "<style type=\"text/css\"> body {text-align: center} </style>"); // so body will align on
                                                                         // center

    out.println("</head>");

    out.println("<body bgcolor=\"#CCCCAA\" text=\"#000000\">");

    out.println("<div style=\"align:center; margin:0px auto;\">");

    if (club.startsWith("tpc") && user.startsWith("passport")) { // if TPC Passport user

      out.println("<br><H3>Welcome to ForeTees</H3><br>");

      String clubname = "";
      String fullname = "";

      Connection con = null;

      try {
        con = dbConn.Connect(rev); // get connection to the Vx db

        //
        //  Get the club names for each TPC club
        //
        PreparedStatement pstmt =
            con.prepareStatement("SELECT fullname FROM clubs WHERE clubname=?");

        pstmt.clearParameters();
        pstmt.setString(1, club);
        ResultSet rs = pstmt.executeQuery();

        if (rs.next()) {

          fullname = rs.getString("fullname"); // get the club's full name
        }

        out.println("<p>You are currently connected to: <b>" + fullname + "</b><br><br>");
        out.println("To continue with this site, simply use the navigation menus above.<br><br>");
        out.println("To switch sites, click on the desired club name below.</p><br>");

        //
        //  Get the club names for each TPC club
        //
        pstmt =
            con.prepareStatement(
                "SELECT clubname, fullname FROM clubs WHERE inactive=0 AND clubname LIKE 'tpc%' ORDER BY fullname");

        pstmt.clearParameters();
        rs = pstmt.executeQuery();

        while (rs.next()) {

          clubname = rs.getString("clubname"); // get a club name

          if (clubname.startsWith("tpc")) {

            fullname = rs.getString("fullname"); // get the club's full name

            out.println(
                "<a href=\"Hotel_home?clubswitch=1&club="
                    + clubname
                    + "\" target=_top>"
                    + fullname
                    + "</a><br>");
          }
        }
        pstmt.close();

      } catch (Exception e) {

        // Error connecting to db....
        out.println(
            "<BR><BR>Sorry, we encountered an error while trying to connect to the database.");
        // out.println("<br><br>Error: " + e.toString() + "<br>");
        out.println("<BR><BR> <A HREF=\"Hotel_home\">Return</A>.");
        out.println("</BODY></HTML>");
        return;
      }

    } else {

      out.println(
          "<BR><BR> You have entered here by mistake. Please contact ForeTees Support at 651-765-6006.");
      out.println("</BODY></HTML>");
    }
    out.println("</div></BODY></HTML>");
  } // end of doGet
Beispiel #20
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("image/jpeg");
      pageContext =
          _jspxFactory.getPageContext(
              this, request, response, "/myhtml/errorpage/erroe.jsp", true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write('\r');
      out.write('\n');

      // 设置页面不缓存
      response.setHeader("Pragma", "No-cache");
      response.setHeader("Cache-Control", "no-cache");
      response.setDateHeader("Expires", 0);

      //   在内存中创建图象
      int width = 60, height = 20;
      BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

      //   获取图形上下文
      Graphics g = image.getGraphics();

      // 生成随机类
      Random random = new Random();

      //   设定背景色
      g.setColor(getRandColor(200, 250));
      g.fillRect(0, 0, width, height);

      // 设定字体
      g.setFont(new Font("Times   New   Roman", Font.PLAIN, 18));

      // 画边框
      // g.setColor(new   Color());
      // g.drawRect(0,0,width-1,height-1);

      //   随机产生155条干扰线,使图象中的认证码不易被其它程序探测到
      g.setColor(getRandColor(160, 200));
      for (int i = 0; i < 155; i++) {
        int x = random.nextInt(width);
        int y = random.nextInt(height);
        int xl = random.nextInt(12);
        int yl = random.nextInt(12);
        g.drawLine(x, y, x + xl, y + yl);
      }

      //   取随机产生的认证码(4位数字)
      String sRand = "";
      for (int i = 0; i < 4; i++) {
        String rand = String.valueOf(random.nextInt(10));
        sRand += rand;
        //   将认证码显示到图象中
        g.setColor(
            new Color(
                20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));
        // 调用函数出来的颜色相同,可能是å›
        // ä¸ºç§å­å¤ªæŽ¥è¿‘,所以只能直接生成
        g.drawString(rand, 13 * i + 6, 16);
      }

      //   将认证码存入SESSION
      session.setAttribute("rand", sRand);

      //   图象生效
      g.dispose();

      //   输出图象到页面
      ImageIO.write(image, "JPEG", response.getOutputStream());
      out.clear();
      out = pageContext.pushBody();

    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try {
            out.clearBuffer();
          } catch (java.io.IOException e) {
          }
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
        else log(t.getMessage(), t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Beispiel #21
0
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    server svr = new server();
    response.setContentType("text/html");
    HttpSession session = request.getSession(true);
    PrintWriter out = response.getWriter();
    String email = request.getParameter("email");
    String pw1 = request.getParameter("pw1");
    String pw2 = request.getParameter("pw2");
    String error = null;
    String username = session.getAttribute("username").toString();
    if (pw1.compareTo(pw2) != 0) {
      error = "Passwords do not match";
      session.setAttribute("ErrorMessage", error);
      response.sendRedirect("home.jsp");
    }
    try {
      Statement st = null;
      String strQuery = null;
      if ((pw1.length() == 0) && (email.length() == 0)) {
        session.setAttribute("ErrorMessage", "Nothing to change!");
        response.sendRedirect("home.jsp");
      } else if ((pw1.length() != 0) && (email.length() != 0)) {
        strQuery =
            "UPDATE `twitter2012`.`users` SET `password`='"
                + pw1
                + "', `email_address`='"
                + email
                + "' WHERE `username`='"
                + username
                + "'";
        session.setAttribute("email", email);
      } else if ((pw1.length() == 0) && (email.length() != 0)) {
        strQuery =
            "UPDATE `twitter2012`.`users` SET `email_address`='"
                + email
                + "' WHERE `username`='"
                + username
                + "'";
        session.setAttribute("email", email);
      } else if ((pw1.length() != 0) && (email.length() == 0)) {
        strQuery =
            "UPDATE `twitter2012`.`users` SET `password`='"
                + pw1
                + "' WHERE `username`='"
                + username
                + "'";
      }
      Connection dbcon = null;
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      dbcon = DriverManager.getConnection(svr.getURL(), svr.getUN(), svr.getPW());
      st = dbcon.createStatement();
      st.executeUpdate(strQuery);
      session.setAttribute("ErrorMessage", "Details Changed");
      dbcon.close();
      session.setAttribute("ErrorMessage", "Details Changed");
      response.sendRedirect("home.jsp");
    } catch (Exception ex) {
      out.println(ex);
    }
  }
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    boolean orderCompleted = true;

    // Get the user's session and shopping cart
    HttpSession session = request.getSession(true);
    ResourceBundle messages = (ResourceBundle) session.getAttribute("messages");
    ShoppingCart cart = (ShoppingCart) session.getAttribute("cart");

    if (cart == null) {
      cart = new ShoppingCart();
      session.setAttribute("cart", cart);
    }

    // Update the inventory
    try {
      utx.begin();
      bookDB.buyBooks(cart);
      utx.commit();
    } catch (Exception ex) {
      try {
        utx.rollback();
      } catch (Exception e) {
        System.out.println("Rollback failed: " + e.getMessage());
      }

      System.err.println(ex.getMessage());
      orderCompleted = false;
    }

    // Payment received -- invalidate the session
    session.invalidate();

    // set content type header before accessing the Writer
    response.setContentType("text/html");
    response.setBufferSize(8192);

    PrintWriter out = response.getWriter();

    // then write the response
    out.println(
        "<html>" + "<head><title>" + messages.getString("TitleReceipt") + "</title></head>");

    // Get the dispatcher; it gets the banner to the user
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/banner");

    if (dispatcher != null) {
      dispatcher.include(request, response);
    }

    if (orderCompleted) {
      out.println("<h3>" + messages.getString("ThankYou") + request.getParameter("cardname") + ".");
    } else {
      out.println("<h3>" + messages.getString("OrderError"));
    }

    out.println(
        "<p> &nbsp; <p><strong><a href=\""
            + response.encodeURL(request.getContextPath())
            + "/bookstore\">"
            + messages.getString("ContinueShopping")
            + "</a> &nbsp; &nbsp; &nbsp;"
            + "</body></html>");
    out.close();
  }
Beispiel #23
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    response.setContentType("text/html");
    HttpSession session =
        request.getSession(true); // ��� �������� ������� ������ ������������� ����� true
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");

    String phoneToDelete = request.getParameter("phoneToDelete");
    String currentName = request.getParameter("name"); // �������� ������
    String newPrice = request.getParameter("finPrice"); // �������� ���� ������
    String number = request.getParameter("number"); // ���������� ������
    String phonesRequestLine = (String) session.getAttribute("phonesRequestLine");
    StringTokenizer tok = null;

    iPhonePageBean[] iPhones = (iPhonePageBean[]) session.getAttribute("iPhones");
    int summary = 0; // �������� ���� �������
    boolean isNew = true;

    if (phonesRequestLine != null) {
      phonesRequestLine = rebuildStringWithException(phonesRequestLine, "null");
      tok = new StringTokenizer(phonesRequestLine);
    }

    if (currentName != null && newPrice != null && number != null)
      if (isNumber(Integer.parseInt(number)) && isNumber(Integer.parseInt(newPrice))) {
        for (int i = 0; i < iPhones.length; ++i)
          if (iPhones[i].getName().equals(currentName)) {
            iPhones[i].setNumber(number);
            iPhones[i].setFinalPrice(newPrice);

            break;
          }
      }

    for (int i = 0; i < iPhones.length; ++i)
      if (!iPhones[i].getNumber().equals("0")) {
        isNew = false;

        break;
      }

    if (isNew) {
      while (tok.hasMoreElements()) {
        String temp = tok.nextToken();

        for (int i = 0; i < iPhones.length; ++i)
          if (iPhones[i].getName().equals(temp)) {
            iPhones[i].setNumber("1");
            summary += iPhones[i].getPrice();
          }
      }
    } else {
      for (int i = 0; i < iPhones.length; ++i) {
        summary += (Integer.parseInt(iPhones[i].getNumber()) * iPhones[i].getPrice());
      }
    }

    ////////////////////////////////////////////////////////////////////////

    if (phoneToDelete != null && phonesRequestLine != null) {
      phonesRequestLine = rebuildStringWithException(phonesRequestLine, phoneToDelete);

      int tempID = idOfSpecPhone(iPhones, phoneToDelete);

      if (tempID >= 0) {
        summary =
            summary - (iPhones[tempID].getPrice() * Integer.parseInt(iPhones[tempID].getNumber()));
      }

      iPhones[tempID].setNumber("0");

      session.setAttribute("phonesRequestLine", phonesRequestLine);
    }

    session.setAttribute("summary", summary);

    RequestDispatcher dispatcher =
        request.getRequestDispatcher("cart.jsp?lang=" + (String) session.getAttribute("lang"));
    dispatcher.forward(request, response);
  }
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<br><h4>we are getting data</h4>");
    String code = request.getParameter("code");
    out.println("<br>code: " + code);
    out.println("<br>");
    try {
      OAuthClientRequest requestOAuth =
          OAuthClientRequest.tokenLocation("https://graph.facebook.com/oauth/access_token")
              .setGrantType(GrantType.AUTHORIZATION_CODE)
              .setClientId(apiKey)
              .setClientSecret(secretKey)
              .setRedirectURI(redirectUri)
              .setCode(code)
              .buildBodyMessage();

      OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());

      GitHubTokenResponse oAuthResponse =
          oAuthClient.accessToken(requestOAuth, GitHubTokenResponse.class);
      accessToken = oAuthResponse.getAccessToken();
      expiresIn = oAuthResponse.getExpiresIn();
    } catch (OAuthSystemException ae) {
      ae.printStackTrace();
    } catch (OAuthProblemException pe) {
      pe.printStackTrace();
    }

    // out.println("<br>Access Token: " + accessToken);
    // out.println("<br>Expires In: " + expiresIn);

    try {
      FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
      myFriends = facebookClient.fetchConnection("me/friends", User.class);
      myFeeds = facebookClient.fetchConnection("me/home", Post.class);

      for (User myFriend : myFriends.getData()) {
        f.add(myFriend.getName());
        out.println("<br>id: " + myFriend.getId() + " Name: " + myFriend.getName());
      }
      //	out.println("<br>");
      out.println("<br>f count: " + f.size());
    } catch (FacebookException e) {
      e.printStackTrace();
    }

    facebookDataBean fdb = new facebookDataBean();
    fdb.setName("zishan ali khan");
    HttpSession session = request.getSession();
    if (session != null) {
      session.setAttribute("myfdb", fdb);
      session.setAttribute("yourFriends", f);
      session.setAttribute("feeds", myFeeds);
      RequestDispatcher view = request.getRequestDispatcher("result.jsp");
      view.forward(request, response);
      f.clear();
      // out.println("<br>I am in");
    } else {
      // out.println("<br>Session Over");
    }
  }
Beispiel #25
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    response.setContentType("text/html");
    HttpSession session = request.getSession(false);
    String reseller = null;
    if (session != null && session.getAttribute("reseller") != null)
      reseller = "%" + session.getAttribute("reseller") + "%";
    List<LicenseData> searchResult = null;
    if (reseller != null) {
      /*  session.setAttribute("fieldsearch", true);
      session.removeAttribute("datesearch");*/

      if (request.getParameter("so") != null && !request.getParameter("so").isEmpty()) {

        log.info(
            "Search Fields : Sales Order Search "
                + request.getParameter("so")
                + " for reseller "
                + session.getAttribute("reseller"));

        searchResult = getSearchByFieldResults(reseller, request.getParameter("so"), "so");

        session.setAttribute("so", request.getParameter("so"));
        session.removeAttribute("enduser");
        session.removeAttribute("ek");
        session.setAttribute("label", "Sales Order");
        session.setAttribute("value", request.getParameter("so"));

      } else if (request.getParameter("enduser") != null
          && !request.getParameter("enduser").isEmpty()) {

        log.info(
            "Search Fields : End User Search "
                + request.getParameter("enduser")
                + " for reseller "
                + session.getAttribute("reseller"));

        searchResult =
            getSearchByFieldResults(reseller, request.getParameter("enduser"), "enduser");
        session.setAttribute("enduser", request.getParameter("enduser"));
        session.removeAttribute("so");
        session.removeAttribute("sno");
        session.removeAttribute("ek");
        session.setAttribute("label", "End User");
        session.setAttribute("value", request.getParameter("enduser"));

      } else if (request.getParameter("ek") != null && !request.getParameter("ek").isEmpty()) {

        log.info(
            "Search Fields : Entitlement Key Search "
                + request.getParameter("ek")
                + " for reseller "
                + session.getAttribute("reseller"));

        searchResult = getSearchByFieldResults(reseller, request.getParameter("ek"), "ek");
        session.setAttribute("ek", request.getParameter("ek"));
        session.removeAttribute("so");
        session.removeAttribute("sno");
        session.removeAttribute("enduser");
        session.setAttribute("label", "Entitlement Key");
        session.setAttribute("value", request.getParameter("ek"));

      } else if (request.getParameter("sno") != null && !request.getParameter("sno").isEmpty()) {

        log.info(
            "Search Fields : Serial Number Search "
                + request.getParameter("sno")
                + " for reseller "
                + session.getAttribute("reseller"));

        searchResult = getSearchByFieldResults(reseller, request.getParameter("sno"), "sno");
        session.setAttribute("sno", request.getParameter("sno"));
        session.removeAttribute("ek");
        session.removeAttribute("so");
        session.removeAttribute("enduser");
        request.setAttribute("sno", 1);
        session.setAttribute("label", "Serial Number");
        session.setAttribute("value", request.getParameter("sno"));

      } else if (request.getParameter("po") != null && !request.getParameter("po").isEmpty()) {

        log.info(
            "Search Fields : Purchase Order Search "
                + request.getParameter("po")
                + " for reseller "
                + session.getAttribute("reseller"));

        searchResult = getSearchByFieldResults(reseller, request.getParameter("po"), "po");
        session.setAttribute("po", request.getParameter("po"));
        session.setAttribute("label", "Purchase Order");
        session.setAttribute("value", request.getParameter("po"));

      } else if (request.getParameter("hm") != null && !request.getParameter("hm").isEmpty()) {

        log.info(
            "Search Fields : HM ID Search "
                + request.getParameter("hm")
                + " for reseller "
                + session.getAttribute("hm"));

        searchResult = getSearchByFieldResults(reseller, request.getParameter("hm"), "hm");
        session.setAttribute("hm", request.getParameter("hm"));
        session.setAttribute("label", "Hive Manager ID");
        session.setAttribute("value", request.getParameter("hm"));
      }

      session.setAttribute("fieldSearchList", searchResult);
      String nextJSP = "/viewFieldSearchResult.jsp";
      RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
      dispatcher.forward(request, response);
    } else {

      log.info("Search Fields : Reseller Blank  ");
      String nextJSP = "/login.jsp";
      RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
      dispatcher.forward(request, response);
    }
  }
  /** Common request handling. */
  public void service(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    resetState();
    boolean success = false;
    HttpSession session = req.getSession(false);
    try {
      this.req = req;
      this.resp = resp;
      if (log.isDebug()) {
        logParams();
      }
      resp.setContentType("text/html");

      if (!mayPageBeCached()) {
        resp.setHeader("pragma", "no-cache");
        resp.setHeader("Cache-control", "no-cache");
      }

      reqURL = new URL(UrlUtil.getRequestURL(req));
      clientAddr = getLocalIPAddr();

      // check that current user has permission to run this servlet
      if (!isServletAllowed(myServletDescr())) {
        displayWarningInLieuOfPage("You are not authorized to use " + myServletDescr().heading);
        return;
      }

      // check whether servlet is disabled
      String reason = ServletUtil.servletDisabledReason(myServletDescr().getServletName());
      if (reason != null) {
        displayWarningInLieuOfPage("This function is disabled. " + reason);
        return;
      }
      if (session != null) {
        session.setAttribute(SESSION_KEY_RUNNING_SERVLET, getHeading());
        String reqHost = req.getRemoteHost();
        String forw = req.getHeader(HttpFields.__XForwardedFor);
        if (!StringUtil.isNullString(forw)) {
          reqHost += " (proxies for " + forw + ")";
        }
        session.setAttribute(SESSION_KEY_REQUEST_HOST, reqHost);
      }
      lockssHandleRequest();
      success = (errMsg == null);
    } catch (ServletException e) {
      log.error("Servlet threw", e);
      throw e;
    } catch (IOException e) {
      log.error("Servlet threw", e);
      throw e;
    } catch (RuntimeException e) {
      log.error("Servlet threw", e);
      throw e;
    } finally {
      if (session != null) {
        session.setAttribute(SESSION_KEY_RUNNING_SERVLET, null);
        session.setAttribute(LockssFormAuthenticator.__J_AUTH_ACTIVITY, TimeBase.nowMs());
      }
      if ("please".equalsIgnoreCase(req.getHeader("X-Lockss-Result"))) {
        log.debug3("X-Lockss-Result: " + (success ? "Ok" : "Fail"));
        resp.setHeader("X-Lockss-Result", success ? "Ok" : "Fail");
      }
      resetMyLocals();
      resetLocals();
    }
  }
 private void endHereCommon() throws BeanException {
   // save EJB object handle in property
   if (ejb != null) {
     try {
       hPubAccessHandle = ejb.getHandle();
     } catch (Exception e) {
       String errMsg =
           (new Date(System.currentTimeMillis())).toString()
               + " HPS5955 "
               + this.getClass().getName()
               + ": ejb.getHandle(), ejb="
               + ejb
               + ": "
               + e.getClass().getName()
               + ": "
               + e.getMessage();
       System.err.println(errMsg);
       if (tracing == true) {
         traceArgs[0] = this;
         traceArgs[1] = errMsg;
         try {
           traceMethod.invoke(o, traceArgs);
         } catch (Exception x) {
         }
       }
       throw new BeanException(errMsg);
     }
   }
   // save ejb accessHandle and hpubLinkKey in HttpSession
   if ((oHttpServletRequest != null) && (outputProps != null)) {
     // a new HPubEjb2HttpSessionBindingListener object containing the ejb access
     // handle and hPubLinkKey for the connection is bound to the session using
     // a prefix and the ending connection state of the IO just processed.
     // This hPubLinkKey uniquely identifies the connection associated with the
     // IO chain for that HP Runtime JVM.
     // The ejb access handle is contained within the HPubEjb2HttpSessionBindingListener
     // object so that an ejb remove can be issued in the case where a session
     // timeout or session invalidation occurs for an incomplete IO chain.
     HttpSession theWebsession = oHttpServletRequest.getSession(true);
     if (theWebsession != null) {
       synchronized (theWebsession) {
         try {
           String theKey = KEY_WEBCONN + outputProps.getHPubEndChainName();
           hPubLinkKey = outputProps.getHPubLinkKey();
           theWebsession.setAttribute(
               theKey, new HPubEJB2HttpSessionBindingListener(hPubAccessHandle, hPubLinkKey));
           if (tracing == true) {
             traceArgs[0] = this;
             traceArgs[1] =
                 "theWebsession.setAttribute("
                     + theKey
                     + ",new HPubEJB2HttpSessionBindingListener("
                     + hPubAccessHandle
                     + ", "
                     + hPubLinkKey
                     + "))";
             try {
               traceMethod.invoke(o, traceArgs);
             } catch (Exception x) {
             }
           }
           if (auditing == true) {
             auditArgs[0] =
                 "\n---\nIN:"
                     + this.getClass().getName()
                     + " "
                     + theKey
                     + " "
                     + hPubAccessHandle
                     + " "
                     + hPubLinkKey
                     + " "
                     + theWebsession.getId();
             auditArgs[1] = theWebsession;
             try {
               auditMethod.invoke(o, auditArgs);
             } catch (Exception x) {
             }
           }
         } catch (Exception e) {
           hPubLinkKey = null; // set to null to force following error logic
         }
       }
     }
     // if an error occurred throw an exception to cause ejb remove to be issued.
     if ((theWebsession == null) || (hPubLinkKey == null)) {
       String errMsg =
           (new Date(System.currentTimeMillis())).toString()
               + " HPS5956 "
               + this.getClass().getName()
               + ": HttpServletRequest.getSession(true), hPubLinkKey="
               + hPubLinkKey;
       System.err.println(errMsg);
       if (tracing == true) {
         traceArgs[0] = this;
         traceArgs[1] = errMsg;
         try {
           traceMethod.invoke(o, traceArgs);
         } catch (Exception x) {
         }
       }
       throw new BeanException(errMsg);
     }
   }
   // send Event to User indicating that the Query request is complete
   RequestCompleteEvent hPubEvent = new RequestCompleteEvent(this);
   fireHPubReqCompleteEvent(hPubEvent);
   return;
 }
Beispiel #28
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");

      String path = request.getContextPath();
      String basePath =
          request.getScheme()
              + "://"
              + ("xsaqjy".equals(request.getServerName())
                  ? "xsaqjy.ljgps.net"
                  : request.getServerName())
              + (request.getServerPort() == 80 ? "" : ":" + request.getServerPort())
              + path
              + "/";
      Long userno = (Long) session.getAttribute("userno"); // 获得当前登录用户的id用户号
      if (userno == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
        return;
      }
      Long admin = (Long) session.getAttribute("adminflag"); // 获得标记当前登录用户是否为数据管理员
      if (admin == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
      }
      Long dwtype = (Long) session.getAttribute("dwtype"); // 获得当前登录用户所在单位类型 0代表交警  1代表货运公司
      if (dwtype == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
      }
      String username = (String) request.getSession().getAttribute("username");
      if (username == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
      }
      List<String> list = (List<String>) session.getAttribute("list"); // 获得权限的集合
      if (list == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
      }
      Long userid = (long) Integer.parseInt((String) request.getSession().getAttribute("driverid"));
      if (userid == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
        return;
      }
      Object u = request.getSession().getAttribute("onlineuser"); // 获得当前登录用户的对象
      if (u == null) {
        response.sendRedirect(basePath + "page/admin/login.jsp");
      } // 假如获得不到用户,就重新定向到登录页面
      session.setAttribute("basePath", basePath); // 把basepath放到session中以便所有的页面使用

      out.write("\r\n");
      out.write("\r\n");
      out.write("<!-- 获取当前日期,时间,星期 -->\r\n");

      String week = "";
      if (new Date().getDay() == 0) week = "星期日";
      if (new Date().getDay() == 1) week = "星期一";
      if (new Date().getDay() == 2) week = "星期二";
      if (new Date().getDay() == 3) week = "星期三";
      if (new Date().getDay() == 4) week = "星期四";
      if (new Date().getDay() == 5) week = "星期五";
      if (new Date().getDay() == 6) week = "星期六";
      java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      java.util.Date currentTime = new java.util.Date(); // 得到当前系统时间
      String date1 = formatter.format(currentTime); // 将日期时间格式化
      String date2 = currentTime.toString(); // 将Date型日期时间转换成字符串形式

      out.write("\r\n");
      out.write(
          "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("<base href=\"");
      out.print(basePath);
      out.write("\" />\r\n");
      out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\r\n");
      out.write("<title>机动车网上交通安全宣传教育监管平台</title>\r\n");
      out.write(
          "<link href=\"page/admin/css/style.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n");
      out.write(
          "<script type=\"text/javascript\" src=\"page/admin/javascript/jquery.min.js\"></script>\r\n");
      out.write("<script type=\"text/javascript\">\r\n");
      out.write("\t$(function() {\r\n");
      out.write("\t\t//setMenuHeight\r\n");
      out.write("\t\t$('.menu').height($(window).height() - 56 - 27 - 26);\r\n");
      out.write("\t\t$('.sidebar').height($(window).height() - 56 - 27 - 26);\r\n");
      out.write("\t\t$('.page').height($(window).height() - 56 - 27 - 26);\r\n");
      out.write("\t\t$('.page iframe').width($(window).width() - 15 - 168);\r\n");
      out.write("\t\t$('.subMenu a[href=\"#\"]').next('ul').toggle();\r\n");
      out.write("\t\t//menu on and off\r\n");
      out.write("\t\t$('.btn').click(function() {\r\n");
      out.write("\t\t\t$('.menu').toggle();\r\n");
      out.write("\r\n");
      out.write("\t\t\tif ($(\".menu\").is(\":hidden\")) {\r\n");
      out.write("\t\t\t\t$('iframe').width($(window).width() - 15 + 5);\r\n");
      out.write("\t\t\t} else {\r\n");
      out.write("\t\t\t\t$('iframe').width($(window).width() - 15 - 168);\r\n");
      out.write("\t\t\t}\r\n");
      out.write("\t\t});\r\n");
      out.write(" \r\n");
      out.write("\t\t//\r\n");
      out.write("\t\t$('.subMenu a[href=\"#\"]').click(function() {\r\n");
      out.write("\t\t\t$(this).next('ul').toggle();\r\n");
      out.write("\t\t\treturn false;\r\n");
      out.write("\t\t});\r\n");
      out.write("\t});\r\n");
      out.write("\t\r\n");
      out.write("\tfunction clickmenu(topage){\r\n");
      out.write("\t\t $('iframe')[0].src = topage;\r\n");
      out.write("\t}\r\n");
      out.write("</script>\r\n");
      out.write("\r\n");
      out.write("<!-- 后台页面权限的分配 -->\r\n");
      out.write("<script type=\"text/javascript\">\r\n");
      out.write("//页面初始化进行\r\n");
      out.write("window.onload = function() \r\n");
      out.write("{\r\n");
      out.write("\tif(\"");
      out.print(admin);
      out.write("\" == \"1\")//数据管理员的id号设置为0,当id号为0时,拥有一切权限\r\n");
      out.write("\t\t{\r\n");
      out.write("\t\t\t$(\"li\").show();\r\n");
      out.write("\t\t\t$(\"#otherreprimand\").remove();\r\n");
      out.write("\t\t\t$(\"#driverreprimand\").remove();\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t\t}\r\n");
      out.write("\telse\r\n");
      out.write("\t\t{\r\n");
      out.write("\t\t$(\"li\").hide();\r\n");
      out.write("\t\t$(\"#subMenu\").show();\r\n");
      out.write("\t\t");

      if (dwtype == 0) // 当登录的账号为交警部门时,默认的显示前台页面的8个模块对应的后台数据管理
      {

        out.write("\r\n");
        out.write("\t\t    $(\"#firstpage\").show();\r\n");
        out.write("\t\t\t$(\"#rulenmanage\").show();\r\n");
        out.write("\t\t\t$(\"#edunmanage\").show();\r\n");
        out.write("\t\t\t$(\"#baseinfo\").show();\r\n");
        out.write("\t\t\t$(\"#policeorgmanage\").show();\r\n");
        out.write("\t\t\t$(\"#companymanage\").show();\r\n");
        out.write("\t\t\t$(\"#carmanage\").show();\r\n");
        out.write("\t\t\t$(\"#drivermanage\").show();\r\n");
        out.write("\t\t\t$(\"#rulenmanage\").show();\r\n");
        out.write("\t\t\t$(\"#branchmanage\").show();\r\n");
        out.write("\t\t\t$(\"#safenoticemanage\").show();\r\n");
        out.write("\t\t\t$(\"#meetnoticemanage\").show();\r\n");
        out.write("\t\t\t$(\"#interchangemanage\").show();\r\n");
        out.write("\t\t\t$(\"#micromessagemanage\").show();\r\n");
        out.write("\t\t\t$(\"#editpassword\").show();\r\n");
        out.write("\t\t\t$(\"#reprimand\").show();\r\n");
        out.write("\t\t\t$(\"#carlist\").show();\r\n");
        out.write("\t");
      }
      out.write("\r\n");
      out.write("\t\r\n");
      out.write("\t");

      if (dwtype == 1) // 当登录的账号为货运部门时,默认显示货运公司对应的后台数据管理
      {

        out.write("\r\n");
        out.write("\t    $(\"#firstpage\").show();\r\n");
        out.write("\t\t$(\"#baseinfo\").show();\r\n");
        out.write("\t\t$(\"#interchangemanage\").show();\r\n");
        out.write("\t\t$(\"#editpassword\").show();\r\n");
        out.write("\t\t$(\"#safelearn\").show();\r\n");
        out.write("\t\t$(\"#otherreprimand\").show();\r\n");
        out.write("\t\t$(\"#drivermanage\").show();\r\n");
        out.write("\t\t$(\"#micromessagemanage\").show();\r\n");
        out.write("\t\t$(\"#carmanage\").show();\r\n");
        out.write("\t\t$(\"#companymanage\").show();\r\n");
      }
      out.write("\r\n");
      out.write("\r\n");

      if (dwtype == 2) // 当登录的账号为货运部门的驾驶员时,默认显示货运公司驾驶员对应的后台数据管理
      {

        out.write("\r\n");
        out.write("    $(\"#firstpage\").show();\r\n");
        out.write("\t$(\"#baseinfo\").show();\r\n");
        out.write("\t$(\"#drivermanage\").show();\r\n");
        out.write("\t$(\"#editpassword\").show();\r\n");
        out.write("\t$(\"#interchangemanage\").show();\r\n");
        out.write("\t$(\"#safelearn\").show();\r\n");
        out.write("\t$(\"#micromessagemanage\").show();\r\n");
        out.write("\t$(\"#driverreprimand\").show();\r\n");
      }
      out.write("\r\n");
      out.write("\t\t");

      if (u != null) {
        String string = "";
        for (int i = 0; i < list.size(); i++) {
          string = list.get(i);

          out.write("\r\n");
          out.write("\t\t$(\"#");
          out.print(string);
          out.write("\").show();\r\n");
          out.write("\t\t");
        }
      }
      out.write("\r\n");
      out.write("      }\r\n");
      out.write("}\r\n");
      out.write("</script>\r\n");
      out.write("</head>\r\n");
      out.write("<body>\r\n");
      out.write(
          "\t<table border=\"0\" width=\"100%\" height=\"100%\"style=\"margin: 0; padding: 0; background-color: #198bc9\">\r\n");
      out.write("\t\t<tr>\r\n");
      out.write("\t\t\t<td colspan=\"3\">\r\n");
      out.write("\t\t\t\t<div id=\"header\">\r\n");
      out.write(
          "\t\t\t\t<table border=\"0\" width=\"100%\" height=\"100%\" style=\"margin: 0; padding: 0;\">\r\n");
      out.write("\t\t\t\t<tr>\r\n");
      out.write("\t\t\t\t<td width=\"50%\" style=\"text-align:left\">\r\n");
      out.write("\t\t\t\t<div class=\"logo fleft\">&nbsp;</div>\r\n");
      out.write("\t\t\t\t</td>\r\n");
      out.write("\t\t\t\t<td width=\"30%\"></td>\r\n");
      out.write("\t\t\t\t<td width=\"20%\" style=\"text-align:right\">\r\n");
      out.write("\t\t\t\t<div  class=\"logoright fleft\" align=\"right\">&nbsp;</div>\r\n");
      out.write("\t\t\t\t</td>\r\n");
      out.write("\t\t\t\t</tr>\r\n");
      out.write("\t\t\t\t</table>\r\n");
      out.write("\t\t\t\t\t</div>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t</tr>\r\n");
      out.write("\t\t\r\n");
      out.write("\t\t<tr>\r\n");
      out.write("\t\t\t<td colspan=\"3\" align=\"left\">\r\n");
      out.write("\t\t\t<div class=\"logofont\" style=\"margin-left:25px\">\r\n");
      out.write(
          "\t\t\t<table border=\"0\" width=\"100%\" height=\"100%\" style=\"margin: 0; padding: 0;\">\r\n");
      out.write("\t\t\t<tr><td align=\"left\">\r\n");
      out.write("\t\t\t<font>用户:");
      out.print(username);
      out.write("&nbsp;&nbsp;时间:");
      out.print(date1);
      out.write("&nbsp;&nbsp;");
      out.print(week);
      out.write("&nbsp;&nbsp;</font>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t\t<td align=\"right\">\r\n");
      out.write(
          "\t\t\t<a href=\"loginout.action\"><font color=\"#FFFFF0\">退出&nbsp;&nbsp;</font></a>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t\t</tr>\r\n");
      out.write("\t\t\t</table>\r\n");
      out.write("\t\t\t</div>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t</tr>\r\n");
      out.write("\t\t\r\n");
      out.write("\t\t<tr>\r\n");
      out.write("\t\t\t<td width=\"168px\">\r\n");
      out.write("\t\t\t\t<div class=\"menu fleft\">\r\n");
      out.write("\t\t\t\t\t<ul>\r\n");
      out.write("\t\t\t\t\t\t<li class=\"subMenuTitle\" id=\"subMenu\">机动车网安教后台管理</li>\r\n");
      out.write("\t\t\t\t\t\t<li class=\"subMenu\" id=\"firstpage\">首页设置</li>\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"stationmanage\"><a href=\"#\">参数配置</a>\r\n");
      out.write("\t\t\t\t\t\t\t<ul>\r\n");
      out.write(
          "\t\t\t\t\t\t\t\t<li><a href=\"javascript:clickmenu('page/admin/page/config_viewConfigList.action')\">网站信息</a>\r\n");
      out.write("\t\t\t\t\t\t\t\t</li>\r\n");
      out.write("\t\t\t\t\t\t\t</ul></li>\r\n");
      out.write("\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"accountmanage\"><a href=\"#\">系统管理</a>\r\n");
      out.write("\t\t\t\t\t\t\t<ul>\r\n");
      out.write(
          "\t\t\t\t\t\t\t\t<li id=\"rolemanage\"><a href=\"javascript:clickmenu('page/admin/page/role_viewRoleList.action')\">角色管理</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t\t\t<li id=\"accountmanage\"><a href=\"javascript:clickmenu('page/admin/page/account_viewAccountList.action')\">账号管理</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t\t\t<li id=\"permisionmanage\"><a href=\"javascript:clickmenu('page/admin/page/permission_viewPermissionList.action')\">权限管理</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t\t\t<li  id=\"areamanage\"><a href=\"javascript:clickmenu('page/admin/page/areaback_viewAreaList.action')\">地域管理</a></li>\r\n");
      out.write("\t\t\t\t\t\t\t</ul>\r\n");
      out.write("\t\t\t\t\t\t</li>\r\n");
      out.write("\t\t\t\t\t\t\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"rulenmanage\"><a href=\"javascript:clickmenu('page/admin/page/ruleback_viewRuleList.action')\">交通法规</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"edunmanage\"><a href=\"javascript:clickmenu('page/admin/page/eduback_viewEduList.action')\">宣教中心</a></li>\r\n");
      out.write("\r\n");
      out.write("\t\t\t\t\t <li class=\"subMenu\" id=\"baseinfo\"><a href=\"#\">基本信息</a>\r\n");
      out.write("\t\t\t\t\t\t <ul>\r\n");
      out.write(
          "\t\t\t\t\t\t    <!-- <li id=\"policeorgmanage\"><a href=\"javascript:clickmenu('page/admin/page/orgback_viewPoliceOrgList.action')\">交警部门</a></li> -->\r\n");
      out.write(
          "\t\t\t\t\t\t    <li  id=\"orgmanage\"><a href=\"javascript:clickmenu('page/admin/page/policeorgback_viewPoliceOrgList.action')\">交警部门</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t    <li class=\"subMenu\" id=\"carlist\"><a href=\"javascript:clickmenu('page/admin/page/policeback_viewPoliceList.action')\">交警信息</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t\t<li id=\"companymanage\"><a href=\"javascript:clickmenu('page/admin/page/companyback_viewCompanyList.action')\">企业安全组</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t\t<li id=\"carmanage\"><a href=\"javascript:clickmenu('page/admin/page/carback_viewCarList.action')\">车辆管理</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t\t<li id=\"drivermanage\"><a href=\"javascript:clickmenu('page/admin/page/driverback_viewDriverList.action')\">驾驶员管理</a></li>\r\n");
      out.write(
          "\t\t\t\t\t\t  \t<li class=\"subMenu\" id=\"editpassword\"><a href=\"javascript:clickmenu('page/admin/page/account_viewPassword.action?id=");
      out.print(userid);
      out.write("')\">修改密码</a></li>\r\n");
      out.write("\t\t\t\t\t\t  </ul>\r\n");
      out.write("\t\t\t\t\t </li>\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"rulenmanage\"><a href=\"javascript:clickmenu('page/admin/page/illegalback_viewIllegalList.action')\">违法查询</a></li>\r\n");
      out.write("\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"branchmanage\"><a href=\"javascript:clickmenu('page/admin/page/branchback_viewBranchList.action')\">快速处理点</a></li>\r\n");
      out.write("\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"safenoticemanage\"><a href=\"javascript:clickmenu('page/admin/page/safenoticeback_viewSafeNoticeList.action')\">安全提醒</a></li>\r\n");
      out.write("\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"meetnoticemanage\"><a href=\"javascript:clickmenu('page/admin/page/meetnoticeback_viewMeetNoticeList.action')\">会议通知</a></li>\r\n");
      out.write("\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"safelearn\"><a href=\"javascript:clickmenu('page/admin/page/safelearnback_viewEduList.action')\">安全教育学习</a></li>\r\n");
      out.write("\t\t\t\t\t\t\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"reprimand\"><a href=\"javascript:clickmenu('page/admin/page/reprimandback_viewReprimandList.action')\">通报批评</a></li>\r\n");
      out.write("\t\t\t\t\t\r\n");
      out.write(
          "\t\t\t\t\t    <li class=\"subMenu\" id=\"otherreprimand\"><a href=\"javascript:clickmenu('page/admin/page/otherreprimandback_viewReprimandList.action')\">通报批评</a></li>\r\n");
      out.write("\t\t\t\t\t    \r\n");
      out.write(
          "\t\t\t\t\t    <li class=\"subMenu\" id=\"driverreprimand\"><a href=\"javascript:clickmenu('page/admin/page/otherreprimandback_showDriverReprimand.action')\">通报批评</a></li>\r\n");
      out.write("\t\t\t\t\t   \r\n");
      out.write(
          "\t\t\t\t\t    <li class=\"subMenu\" id=\"interchangemanage\"><a href=\"javascript:clickmenu('page/admin/page/interchangeback_viewInterchangeList.action')\">问题答疑</a></li>\r\n");
      out.write("\r\n");
      out.write(
          "\t\t\t\t\t\t<li class=\"subMenu\" id=\"micromessagemanage\"><a href=\"javascript:clickmenu('page/admin/page/micromessage/micromessagelist.jsp')\">微博互动</a></li>\r\n");
      out.write("\t\t\t\t\t\r\n");
      out.write("\t\t\t\t\t</ul>\r\n");
      out.write("\t\t\t\t\t\r\n");
      out.write("\t\t\t\t</div>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t\t<td width=\"5px\">\r\n");
      out.write("\t\t\t\t<div class=\"sidebar fleft\">\r\n");
      out.write("\t\t\t\t\t<div class=\"btn\"></div>\r\n");
      out.write("\t\t\t\t</div>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t\t<td class=\"page\"><iframe width=\"100%\" scrolling=\"auto\"\r\n");
      out.write("\t\t\t\t\theight=\"100%\" FRAMEBORDER=0 style=\"border: medium none;\"\r\n");
      out.write(
          "\t\t\t\t\tsrc=\"/TrafficPolice/page/admin/page/Startpage.jsp\" id=\"rightMain\"\r\n");
      out.write("\t\t\t\t\tname=\"right\"></iframe>\r\n");
      out.write("\t\t\t</td>\r\n");
      out.write("\t\t</tr>\r\n");
      out.write("\t\t<tr>\r\n");
      out.write("\t\t\t<td colspan=\"3\"><div id=\"footer\"></div></td>\r\n");
      out.write("\t\t</tr>\r\n");
      out.write("\t</table>\r\n");
      out.write("</body>\r\n");
      out.write("\r\n");
      out.write("</html>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try {
            out.clearBuffer();
          } catch (java.io.IOException e) {
          }
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }