List of usage examples for javax.servlet.http HttpServletRequest getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String path);
From source file:Movies.SearchMovies.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w w w . j a va2 s . 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 { String search = request.getParameter("search"); search = URLEncoder.encode(search, "UTF-8"); URL url = new URL("http://www.omdbapi.com/?s=" + search); ObjectMapper mapper = new ObjectMapper(); Map<String, Object> map = mapper.readValue(url, Map.class); List list = (List) map.get("Search"); request.setAttribute("list", list); request.getRequestDispatcher("movies.jsp").forward(request, response); }
From source file:com.iwancool.dsm.admin.filter.DsmSecurityInterceptor.java
/** * controller?//from ww w. jav a2 s . c o m */ @SuppressWarnings("unchecked") @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { String requestPath = request.getRequestURI().substring(request.getContextPath().length()); //??? if (excludeUrls.contains(requestPath)) return true; // if (!SessionUtils.isLogin(request)) { request.setAttribute("msg", ""); request.getRequestDispatcher("/login/index").forward(request, response); return false; } List<PermissionModel> permissionList = (List<PermissionModel>) SessionUtils.getAttr(request, SessionUtils.ADMIN_PERMISSION_CACHE_KEY); return true; //return hasPermission(permissionList, requestPath); }
From source file:com.sielpe.controller.GestionarCandidatos.java
/** * peticion redireccion a nuevo candidato * * @param request// w ww .j av a 2 s . co m * @param response * @throws IOException * @throws ServletException * @throws MiExcepcion */ public void redireccionNuevoCandidato(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (request.getParameter("add") != null) { ArrayList<Eleccion> eleccionesVigentes = (ArrayList) facadeDAO.eleccionesVigentes(); request.setAttribute("eleccionesVigentes", eleccionesVigentes); request.getRequestDispatcher("nuevoCandidato.jsp").forward(request, response); } else { nuevoCandidato(request, response); } }
From source file:it.volaconnoi.servlet.CheckInServlet.java
/** * Handles the HTTP <code>POST</code> method. * * @param request servlet request//from w w w .j a v a2 s . c o m * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String reserv_id = request.getParameter("reserv_id"); List<Reservation> reserv = reservationBean.getValidReservation(StringUtils.upperCase(reserv_id)); if (reserv != null) { request.setAttribute("reserv", reserv.get(0)); } else { request.setAttribute("notfoundreserv", "Nessuna prenotazione corrispondete al PNR inserito!"); } request.getRequestDispatcher("/WEB-INF/checkin/checkin.jsp").forward(request, response); }
From source file:com.afspq.web.ProcessQuery.java
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) *//*from w ww. ja va 2s. c o m*/ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); String searchType = request.getParameter("searchType"); if (searchType != null && searchType.equals("image")) { request.setAttribute("results", new ImageResults().getResults(request.getParameter("imgQuery"), imageSearch, Integer.parseInt(request.getParameter("similar")), false)); request.getRequestDispatcher("imageResults.jsp").forward(request, response); } else if (searchType != null && searchType.equals("web")) { request.setAttribute("results", new Results().getResults(request.getParameter("query"), fullTextSearch, Integer.parseInt(request.getParameter("page")), 8)); request.getRequestDispatcher("results.jsp").forward(request, response); } }
From source file:org.zkoss.zkgrails.ZKGrailsPageFilter.java
protected void applyDecorator(Page page, Decorator decorator, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String uriPath = decorator.getURIPath(); if (uriPath != null && uriPath.endsWith(".gsp")) { request.setAttribute(PAGE, page); detectContentTypeFromPage(page, response); RequestDispatcher rd = request.getRequestDispatcher(decorator.getURIPath()); if (!response.isCommitted()) { if (LOG.isDebugEnabled()) { LOG.debug("Rendering layout using forward: " + decorator.getURIPath()); }/*from ww w. j av a 2s . c o m*/ rd.forward(request, response); } else { if (LOG.isDebugEnabled()) { LOG.debug("Rendering layout using include: " + decorator.getURIPath()); } request.setAttribute(GrailsApplicationAttributes.GSP_TO_RENDER, decorator.getURIPath()); rd.include(request, response); request.removeAttribute(GrailsApplicationAttributes.GSP_TO_RENDER); } // set the headers specified as decorator init params while (decorator.getInitParameterNames().hasNext()) { String initParam = (String) decorator.getInitParameterNames().next(); if (initParam.startsWith("header.")) { response.setHeader(initParam.substring(initParam.indexOf('.')), decorator.getInitParameter(initParam)); } } request.removeAttribute(PAGE); } else { super.applyDecorator(page, decorator, request, response); } }
From source file:ar.com.zauber.commons.web.filter.HttpRequestHeaderFilter.java
/** @see OncePerRequestFilter#doFilterInternal( * HttpServletRequest, HttpServletResponse, FilterChain) */ @Override/*from www. ja v a 2 s. c o m*/ protected final void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { final String headerValue = request.getHeader(headerName); if (headerValue != null && isAcceptableValue(headerValue)) { //se contina procesando el request filterChain.doFilter(request, response); } else { //se detiene el proceso y redirecciona a target response.setStatus(statusCode); request.getRequestDispatcher(target).forward(request, response); } }
From source file:cn.org.pomer.web.DirectResult.java
private void doDispatcher(HttpServletResponse response, HttpServletRequest request, String resultCodeAsLocation) throws IOException, ServletException { if (_log.isInfoEnabled()) { _log.info("Forwarding to location:" + resultCodeAsLocation); }//from ww w . jav a 2s. co m PageContext pageContext = ServletActionContext.getPageContext(); if (pageContext != null) { pageContext.include(resultCodeAsLocation); return; } RequestDispatcher dispatcher = request.getRequestDispatcher(resultCodeAsLocation); if (dispatcher == null) { response.sendError(404, "result '" + resultCodeAsLocation + "' not found"); return; } if (!response.isCommitted() && (request.getAttribute("javax.servlet.include.servlet_path") == null)) { request.setAttribute("struts.view_uri", resultCodeAsLocation); request.setAttribute("struts.request_uri", request.getRequestURI()); dispatcher.forward(request, response); } else { dispatcher.include(request, response); } }
From source file:Control.LoadImage.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request/*from ww w . ja v a 2 s .co m*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { List<Image> images = loadImages(request, response); request.setAttribute("images", images); } catch (SQLException | ClassNotFoundException ex) { Logger.getLogger(LoadImage.class.getName()).log(Level.SEVERE, null, ex); } RequestDispatcher dispatcher = request.getRequestDispatcher("/LoadImage.jsp"); dispatcher.forward(request, response); }
From source file:com.sielpe.controller.GestionarCandidatos.java
/** * peticion listar Elecciones/*from www . j a va 2 s .com*/ * * @param request * @param response * @throws IOException * @throws ServletException */ public void ListarCandidatos(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (request.getQueryString() == null || request.getParameter("msg") != null) { ArrayList<Candidato> listaCandidatos = (ArrayList) facadeDAO.listarCandidatos(); request.setAttribute("listCandidatos", listaCandidatos); request.getRequestDispatcher("GestionCandidatos.jsp").forward(request, response); } else { redireccionNuevoCandidato(request, response); } }