List of usage examples for javax.servlet.http HttpServletRequest getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String path);
From source file:io.github.benas.todolist.web.servlet.user.account.DeleteAccountServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); userService.remove(user);//w w w . j ava 2s. co m session.invalidate(); request.getRequestDispatcher("/index").forward(request, response); }
From source file:FormServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { response.setContentType("text/html"); java.io.PrintWriter out = response.getWriter(); out.println("<html><head>"); RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/validate.js"); dispatcher.include(request, response); out.println("<title>Help Page</title></head><body>"); out.println("<h2>Please submit your information</h2>"); out.println("<form action =\"" + request.getContextPath() + "/displayHeaders.jsp\" onSubmit=\" return validate(this)\">"); out.println("<table border=\"0\"><tr><td valign=\"top\">"); out.println("Your name: </td> <td valign=\"top\">"); out.println("<input type=\"text\" name=\"username\" size=\"20\">"); out.println("</td></tr><tr><td valign=\"top\">"); out.println("Your email: </td> <td valign=\"top\">"); out.println("<input type=\"text\" name=\"email\" size=\"20\">"); out.println("</td></tr><tr><td valign=\"top\">"); out.println("<input type=\"submit\" value=\"Submit Info\"></td></tr>"); out.println("</table></form>"); out.println("</body></html>"); out.close();/*from w w w . ja v a 2 s. c om*/ }
From source file:edu.ncsu.lib.browse.Browse.java
private void dispatchError(HttpServletRequest request, HttpServletResponse response) { RequestDispatcher errDispatcher = request.getRequestDispatcher("jsp/error.jsp"); try {/*from ww w . jav a 2 s .c om*/ errDispatcher.forward(request, response); } catch (Exception e) { System.out.println("Error forwarding to error.jsp"); e.printStackTrace(); } }
From source file:com.parallax.server.blocklyprop.servlets.HelpSearchServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String queryText = req.getParameter("query"); if (Strings.isNullOrEmpty(queryText)) { req.getRequestDispatcher("/WEB-INF/servlet/help/help-results.jsp").forward(req, resp); return;//w w w . jav a2s.c o m } try { IndexSearcher indexSearcher = initialize(); if (indexSearcher == null) { // TODO return; } Query query = parser.parse(queryText); TopDocs hits = indexSearcher.search(query, 10); if (hits.totalHits > 0) { StringBuilder s = new StringBuilder(); for (ScoreDoc scoreDoc : hits.scoreDocs) { Document document = indexSearcher.doc(scoreDoc.doc); String title = document.get("title"); String shortDescription = document.get("short"); String path = document.get("path"); s.append("<div class='result'><div class='result-body'><h4><a href='help?f=").append(path) .append("'>").append(title).append("</a></h4>"); if (shortDescription != null) { s.append("<p>"); s.append(shortDescription); s.append("</p>"); } s.append("</div></div>"); } req.setAttribute("html", s.toString()); req.getRequestDispatcher("/WEB-INF/servlet/help/help-results.jsp").forward(req, resp); } else { req.getRequestDispatcher("/WEB-INF/servlet/help/help-results.jsp").forward(req, resp); } } catch (ParseException ex) { Logger.getLogger(HelpSearchServlet.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:web.KategoriServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w . j a va2s . c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { EntityManager em = emf.createEntityManager(); KategoriDAO dao = new KategoriDAOImpl(em); request.setAttribute("kategoris", dao.getAll()); RequestDispatcher rd = request.getRequestDispatcher("daftar_kategori.jsp"); rd.forward(request, response); }
From source file:io.muic.ooc.webapp.servlet.AddServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {// w w w . j ava2 s .c o m boolean authorized = securityService.isAuthorized(request); if (authorized) { // do MVC in here RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/add.jsp"); rd.include(request, response); } else { response.sendRedirect("/login"); } } catch (Exception e) { } }
From source file:controller.ControlPembayaran.java
public void returnError(HttpServletRequest request, HttpServletResponse response, Exception e) throws ServletException, IOException { RequestDispatcher dispatcher;//from w ww. j a v a 2s. c o m request.setAttribute("error", e.getMessage()); dispatcher = request.getRequestDispatcher("error.jsp"); dispatcher.forward(request, response); }
From source file:com.gigglinggnus.controllers.AdminViewAppointmentsController.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { EntityManager em = (EntityManager) request.getSession().getAttribute("em"); Clock clk = (Clock) (request.getSession().getAttribute("clock")); RequestDispatcher rd = request.getRequestDispatcher("/admin/view-apmts.jsp"); rd.forward(request, response);/*from w ww. j a v a2 s. c o m*/ }
From source file:controller.ControlPembayaran.java
public void tampil(HttpServletRequest request, HttpServletResponse response, String information) throws ServletException, IOException { RequestDispatcher dispatcher;/* w w w. j a va 2 s .c o m*/ request.setAttribute("info", information); dispatcher = request.getRequestDispatcher("info.jsp"); dispatcher.forward(request, response); }
From source file:controller.controller.java
public void dispatcher(HttpServletRequest request, HttpServletResponse response, String page) throws ServletException, IOException { RequestDispatcher rd = request.getRequestDispatcher(page); rd.forward(request, response);//from w ww .j av a 2 s.c o m }