Beispiel #1
0
 public Result questions1(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException {
   List<Comment> list = dbUtil.listAllOpenQuestions();
   req.setAttribute("comments", list);
   req.getRequestDispatcher("/jsp/query/opens.jsp").forward(req, resp);
   return Result.ok();
 }
Beispiel #2
0
 public Result questions(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException {
   UserInfo u = (UserInfo) req.getSession().getAttribute("user");
   List<Comment> list = dbUtil.questions4Customer(u.username);
   req.setAttribute("comments", list);
   req.getRequestDispatcher("/jsp/customer/list.jsp").forward(req, resp);
   return Result.ok();
 }
Beispiel #3
0
 public Result search(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException {
   String key = req.getParameter("key");
   Paging<Comment> paging = doSearch(key, req, resp);
   req.setAttribute("comments", paging);
   req.getRequestDispatcher("/jsp/query/search.jsp").forward(req, resp);
   return Result.ok();
 }
Beispiel #4
0
 public Result myAnswers(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException {
   UserInfo u = (UserInfo) req.getSession().getAttribute("user");
   String username = u.username;
   List<Comment> list = dbUtil.listMyAnswers(username);
   req.setAttribute("comments", list);
   req.setAttribute("crumb", "mine > my answers");
   req.getRequestDispatcher("/jsp/my/questions.jsp").forward(req, resp);
   return Result.ok();
 }
Beispiel #5
0
  public Result ask(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    String comment = req.getParameter("comment");
    if (!validate(comment)) {
      req.getRequestDispatcher("/jsp/query/ask.jsp").forward(req, resp);
      return Result.error();
    }

    String type = req.getParameter("type");
    if (type.equals("still ask")) {
      doAsk(comment, req);
      return search(req, resp);
    }

    Paging<Comment> list = doSearch(comment, req, resp);
    if (list.data.isEmpty()) {
      doAsk(comment, req);
      return search(req, resp);
    }

    hesitate(comment, req, resp);
    req.getRequestDispatcher("/jsp/query/ask.jsp").forward(req, resp);
    return Result.ok();
  }
Beispiel #6
0
  public Result detail(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    String idStr = req.getParameter("id");
    int id = Integer.parseInt(idStr);
    List<Comment> list = dbUtil.listAnswers(id);
    Comment ask = dbUtil.getCommentById(id);

    req.setAttribute("ask", ask);
    req.setAttribute("answers", list);

    List<UserInfo> customers = dbUtil.listCustomers(ask.project);
    req.setAttribute("customers", customers);

    req.getRequestDispatcher("/jsp/query/answer-list.jsp").forward(req, resp);
    return Result.ok();
  }