@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User user = (User) session.getAttribute("user"); Comment comment = new Comment(); comment.setUserId(user.getUserId()); comment.setNewsId(Integer.parseInt(request.getParameter("news"))); comment.setText(request.getParameter("text")); MessagesBundle messagesBundle = new MessagesBundle(); String errorMessage = messagesBundle.getMessages().get("addCommentFailed"); try { commentService.addComment(comment); List<News> allNews = newsService.getAllNews(user.getUserId()); List<List<Comment>> allComments = commentService.getAllBy(allNews); session.setAttribute("allComments", allComments); response.sendRedirect("/home.jsp"); } catch (DAOException e) { LOGGER.error("Database connection problem", e); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/home.jsp"); request.setAttribute("errorMessage", errorMessage); dispatcher.include(request, response); } }