コード例 #1
0
  /**
   * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   *
   * @param request servlet request
   * @param response servlet response
   */
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    pedidosDAO dao = new pedidosDAO();

    String clavePedido = request.getParameter("clavePedido");

    pedidoBean pedido = new pedidoBean();

    pedido = dao.getPedido(clavePedido);

    String claveCliente = pedido.getClaveCliente();
    String nombreCliente = pedido.getNombreEmpresa();
    String FechaS = pedido.getFecha();
    String detallesPedido = pedido.getDetallesPedido();
    String fechaInicial = pedido.getFechaInicial();
    String fechaFinal = pedido.getFechaFinal();
    String noPedido = pedido.getNoPedido();
    String tipoCambio = pedido.getTipoCambio();
    String tiposIva = pedido.getTipoIva();
    String tipoPedido = pedido.getTipoPedido();

    List listaClientes = new ArrayList();

    listaClientes = dao.getClientes();

    String mensaje = "";

    if (pedido.getClavePedido() == null) {
      mensaje = "¡Numero de pedido No encontrado!";
      RequestDispatcher rdExito =
          request.getRequestDispatcher("/jsp/Pedido/cargaModificarPedido.jsp");

      request.setAttribute("mensaje", mensaje);

      rdExito.forward(request, response);
    } else {

      RequestDispatcher rdExito = request.getRequestDispatcher("/jsp/Pedido/modificarPedido.jsp");

      request.setAttribute("FechaS", FechaS);
      request.setAttribute("mensaje", mensaje);
      request.setAttribute("clavePedido", clavePedido);
      request.setAttribute("claveCliente", claveCliente);
      request.setAttribute("nombreCliente", nombreCliente);
      request.setAttribute("detallesPedido", detallesPedido);
      request.setAttribute("fechaFinal", fechaFinal);
      request.setAttribute("noPedido", noPedido);
      request.setAttribute("tipoCambio", tipoCambio);
      request.setAttribute("tiposIva", tiposIva);
      request.setAttribute("tipoPedido", tipoPedido);
      request.setAttribute("listaClientes", listaClientes);
      request.setAttribute("fechaInicial", fechaInicial);

      rdExito.forward(request, response);
    }
  }
コード例 #2
0
  /**
   * @param request The servlet request we are processing
   * @param result The servlet response we are creating
   * @param chain The filter chain we are processing
   * @exception IOException if an input/output error occurs
   * @exception ServletException if a servlet error occurs
   */
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
      throws IOException, ServletException {
    // once session invalidated, go back to login screen
    HttpServletRequest req = (HttpServletRequest) request;
    HttpSession session = req.getSession();
    String login = (String) session.getAttribute("login");
    if (login != null && login.equals("Y")) {
      chain.doFilter(request, response);
    } else {
      RequestDispatcher rd = request.getRequestDispatcher("/myadmin/logout.jsp");
      rd.forward(request, response);
    }

    // chain.doFilter(request, response);
  }
コード例 #3
0
ファイル: tabSearch.java プロジェクト: robek2020/final4010
  @Override
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException, ServletException {
    // HttpSession sesh = request.getSession();
    // int id = 0;
    // id = (Integer) sesh.getAttribute("id");
    // if (id != 0) {
    RequestDispatcher dis = request.getRequestDispatcher("search.jsp");
    dis.forward(request, response);
    // }
    // else {
    // RequestDispatcher dis = request.getRequestDispatcher("login.jsp");
    // dis.forward(request, response);
    // }

  }
コード例 #4
0
 protected void processRequest(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   // retrieving values from input fields of matrixinput.jsp
   String sMatrix1 = request.getParameter("firstMatrix");
   String sMatrix2 = request.getParameter("secondMatrix");
   // Creating MatrixMultipler object
   MatrixMultiplier mm = new MatrixMultiplier();
   // Passing Strings to convertToObject() method of MatrixMultiplier
   // convertToObject() is used to convert strings into MatrixBean
   MatrixBean fMatrix = mm.convertToObject(sMatrix1);
   MatrixBean sMatrix = mm.convertToObject(sMatrix2);
   // passing MatrixBean’s objects to multiply() method of
   // MatrixMultiplier and receiving the product matrix in the form
   // of MatrixBean
   MatrixBean rMatrix = mm.multiply(fMatrix, sMatrix);
   // saving results in database
   mm.saveResult(rMatrix);
   // storing the product of matrices into request, so that it can be
   // retrieved on matrixresult.jsp
   request.setAttribute("product", rMatrix);
   // forwarding request to matrixresult.jsp
   RequestDispatcher rd = request.getRequestDispatcher("matrixresult.jsp");
   rd.forward(request, response);
 } // end processRequest()
  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");
    }
  }