Tabnine Logo
HttpServletRequest.getRequestDispatcher
Code IndexAdd Tabnine to your IDE (free)

How to use
getRequestDispatcher
method
in
javax.servlet.http.HttpServletRequest

Best Java code snippets using javax.servlet.http.HttpServletRequest.getRequestDispatcher (Showing top 20 results out of 3,114)

Refine searchRefine arrow

  • RequestDispatcher.forward
  • HttpServletRequest.setAttribute
  • HttpServletRequest.getParameter
origin: stackoverflow.com

 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  try {
    List<Product> products = productService.list(); // Obtain all products.
    request.setAttribute("products", products); // Store products in request scope.
    request.getRequestDispatcher("/WEB-INF/products.jsp").forward(request, response); // Forward to JSP page to display them in a HTML table.
  } catch (SQLException e) {
    throw new ServletException("Retrieving products failed!", e);
  }
}
origin: stackoverflow.com

 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  String username = request.getParameter("username");
  String password = request.getParameter("password");
  User user = userService.find(username, password);

  if (user != null) {
    request.getSession().setAttribute("user", user); // Login user.
    response.sendRedirect("home"); // Redirect to home page.
  } else {
    request.setAttribute("message", "Unknown username/password. Please retry."); // Store error message in request scope.
    request.getRequestDispatcher("/WEB-INF/login.jsp").forward(request, response); // Forward to JSP page to redisplay login form with error.
  }
}
origin: spring-projects/spring-framework

@Override
public void forward(String path) throws ServletException, IOException {
  this.request.getRequestDispatcher(path).forward(this.request, this.response);
}
origin: stackoverflow.com

 protected void doGet(HttpServletRequest request, HttpServletResponse response)         throws ServletException, IOException 
{
  String usuario = request.getParameter("usuario");
  JOptionPane.showMessageDialog( null, "El usuario que usa esto es " + usuario );

  request.setAttribute("usuario",usuario);
  RequestDispatcher rd=request.getRequestDispatcher("/jsp/PantallasGestion/tipoPapel.jsp");
  rd.forward(request,response);
}
origin: javaee-samples/javaee7-samples

@Override
public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject) throws AuthException {
  try {
    HttpServletRequest request = (HttpServletRequest) messageInfo.getRequestMessage();
    HttpServletResponse response = (HttpServletResponse) messageInfo.getResponseMessage();
    if ("include".equals(request.getParameter("dispatch"))) {
      request.getRequestDispatcher("/includedServlet")
          .include(request, response);
      // "Do nothing", required protocol when returning SUCCESS
      handler.handle(new Callback[] { new CallerPrincipalCallback(clientSubject, (Principal) null) });
      // When using includes, the response stays open and the main
      // resource can also write to the response
      return SUCCESS;
    } else {
      request.getRequestDispatcher("/forwardedServlet")
          .forward(request, response);
      // MUST NOT invoke the resource, so CAN NOT return SUCCESS here.
      return SEND_CONTINUE;
    }
    
  } catch (IOException | ServletException | UnsupportedCallbackException e) {
    throw (AuthException) new AuthException().initCause(e);
  }
}
origin: ocpsoft/prettytime

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  request.setAttribute("myDate", new Date());
  request.getRequestDispatcher("/WEB-INF/index.jsp").forward(request, response);
}
origin: cloudfoundry/uaa

protected void validateParamsAndContinue(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
  for (Map.Entry<String, String[]> entry : request.getParameterMap().entrySet()) {
    if (entry.getValue() != null && entry.getValue().length >0) {
      for (String s : entry.getValue()) {
        if (hasText(s) && s.contains(NULL_STRING)) {
          response.setStatus(400);
          request.setAttribute("error_message_code", "request.invalid_parameter");
          request.getRequestDispatcher("/error").forward(request,response);
          return;
        }
      }
    }
  }
  chain.doFilter(request, response);
}
origin: pl.edu.icm.synat/synat-portal-core

private void forwardToOriginalPage(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
  String redirectUri = request.getParameter(REDIRECT_URI_PARAM);
  String method = request.getParameter(METHOD_PARAM);
  HttpServletRequest oldRequest = new MethodAndParametersChangeHttpServletRequest(
      request, method, HttpServletRequestUtils.filterParametersMap(request.getParameterMap(), filteredParameters));
  RequestDispatcher dispatch = request.getRequestDispatcher(redirectUri);
  dispatch.forward(oldRequest, response);
}
origin: cloudfoundry/uaa

@Before
public void setup() throws Exception {
  request = mock(HttpServletRequest.class);
  response = mock(HttpServletResponse.class);
  requestDispatcher = mock(RequestDispatcher.class);
  email = "test@test.org";
  code = "12345";
  password = "mypassword";
  passwordConfirmation = "mypassword";
  messageCode = "form_error";
  when(request.getParameter("email")).thenReturn(email);
  when(request.getParameter("code")).thenReturn(code);
  when(request.getParameter("password")).thenReturn(password);
  when(request.getParameter("password_confirmation")).thenReturn(passwordConfirmation);
  when(request.getRequestDispatcher(anyString())).thenReturn(requestDispatcher);
  entryPoint = new ResetPasswordAuthenticationEntryPoint();
}
origin: stackoverflow.com

 @WebServlet("/product")
public class ProductServlet extends HttpServlet {

  @EJB
  private ProductService productService;

  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Product product = productService.find(request.getParameter("id"));
    request.setAttribute("product", product); // Will be available as ${product} in JSP
    request.getRequestDispatcher("/WEB-INF/product.jsp").forward(request, response);
  }

}
origin: stackoverflow.com

public class YourServlet extends HttpServlet{
   public void doGet(HttpServletRequest request, HttpServletResponse   
   response) throws IOException{
     String search = request.getParameter("search");
      if (search != null) {
        request.setAttribute("search", search);
       RequestDispatcher rd =  
        request.getRequestDispatcher("Content");
       rd.forward(request, response);
 }
   }
 }
origin: javaee-samples/javaee7-samples

HttpServletResponse response = (HttpServletResponse) messageInfo.getResponseMessage();
if ("include".equals(request.getParameter("dispatch"))) {
  if ("jsf".equals(request.getParameter("tech"))) {
    target = "/include.jsf";
  } else  if ("jsfcdi".equals(request.getParameter("tech"))) {
    target = "/include-cdi.jsf";
  request.getRequestDispatcher(target)
      .include(request, response);
  request.getRequestDispatcher(target)
      .forward(request, response);
origin: DeemOpen/zkui

@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain fc) throws IOException, ServletException {
  HttpServletRequest request = (HttpServletRequest) req;
  HttpServletResponse response = (HttpServletResponse) res;
  if (!request.getRequestURI().contains("/login") && !request.getRequestURI().contains("/acd/appconfig")) {
    RequestDispatcher dispatcher;
    HttpSession session = request.getSession();
    if (session != null) {
      if (session.getAttribute("authName") == null || session.getAttribute("authRole") == null) {
        response.sendRedirect("/login");
        return;
      }
    } else {
      request.setAttribute("fail_msg", "Session timed out!");
      dispatcher = request.getRequestDispatcher("/Login");
      dispatcher.forward(request, response);
      return;
    }
  }
  fc.doFilter(req, res);
}
origin: stackoverflow.com

 @Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  List<Product> products = someProductService.list();

  request.setAttribute("products", products);
  request.getRequestDispatcher("/WEB-INF/xml/products.jsp").forward(request, response);
}
origin: gocd/gocd

@RequestMapping(value = "/repository/restful/artifact/GET/*", method = RequestMethod.GET)
public void fetch(HttpServletRequest request, HttpServletResponse response) throws Exception {
  request.getRequestDispatcher("/repository/restful/artifact/GET/html").forward(request, response);
}
origin: stackoverflow.com

 @Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  Integer left = Integer.valueOf(request.getParameter("left"));
  Integer right = Integer.valueOf(request.getParameter("right"));
  Integer sum = left + right;

  request.setAttribute("sum", sum); // It'll be available as ${sum}.
  request.getRequestDispatcher("calculator.jsp").forward(request, response); // Redisplay JSP.
}
origin: stackoverflow.com

protected void doGet(HttpServletRequest request, HttpServletResponse   response) throws ServletException,IOException{
   String prefix =request.getParameter("query");
   ArrayList<String> matchingSuggestions =  suggestions.getAllPrefixMatches(prefix);
   request.setAttribute("suggestions",matchingSuggestions);
   RequestDispatcher rd = request.getRequestDispatcher("/WEB-INF/suggest.jsp");
   rd.forward(request,response);
 }
origin: org.eclipse.jetty/jetty-security

final String username = request.getParameter(__J_USERNAME);
final String password = request.getParameter(__J_PASSWORD);
  RequestDispatcher dispatcher = request.getRequestDispatcher(_formErrorPage);
  response.setHeader(HttpHeader.CACHE_CONTROL.asString(),HttpHeaderValue.NO_CACHE.asString());
  response.setDateHeader(HttpHeader.EXPIRES.asString(),1);
  dispatcher.forward(new FormRequest(request), new FormResponse(response));
RequestDispatcher dispatcher = request.getRequestDispatcher(_formLoginPage);
response.setHeader(HttpHeader.CACHE_CONTROL.asString(),HttpHeaderValue.NO_CACHE.asString());
response.setDateHeader(HttpHeader.EXPIRES.asString(),1);
dispatcher.forward(new FormRequest(request), new FormResponse(response));
origin: org.springframework.boot/spring-boot

private void forwardToErrorPage(String path, HttpServletRequest request,
    HttpServletResponse response, Throwable ex)
    throws ServletException, IOException {
  if (logger.isErrorEnabled()) {
    String message = "Forwarding to error page from request "
        + getDescription(request) + " due to exception [" + ex.getMessage()
        + "]";
    logger.error(message, ex);
  }
  setErrorAttributes(request, 500, ex.getMessage());
  request.setAttribute(ERROR_EXCEPTION, ex);
  request.setAttribute(ERROR_EXCEPTION_TYPE, ex.getClass());
  response.reset();
  response.setStatus(500);
  request.getRequestDispatcher(path).forward(request, response);
  request.removeAttribute(ERROR_EXCEPTION);
  request.removeAttribute(ERROR_EXCEPTION_TYPE);
}
origin: stackoverflow.com

 protected void doGet(HttpServletRequest request, HttpServletResponse response) {
  Map<String, String> countries = MainUtils.getCountries();
  request.setAttribute("countries", countries);
  request.getRequestDispatcher("/WEB-INF/page.jsp").forward(request, response);
}
javax.servlet.httpHttpServletRequestgetRequestDispatcher

Popular methods of HttpServletRequest

  • getHeader
    Returns the value of the specified request header as a String. If the request did not include a head
  • getParameter
  • getRequestURI
    Returns the part of this request's URL from the protocol name up to the query string in the first li
  • getSession
    Returns the current HttpSession associated with this request or, if there is no current session and
  • getMethod
    Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT
  • getAttribute
  • getContextPath
    Returns the portion of the request URI that indicates the context of the request. The context path a
  • getQueryString
    Returns the query string that is contained in the request URL after the path. This method returns nu
  • setAttribute
  • getPathInfo
    Returns any extra path information associated with the URL the client sent when it made this request
  • getRequestURL
    Reconstructs the URL the client used to make the request. The returned URL contains a protocol, serv
  • getRemoteAddr
  • getRequestURL,
  • getRemoteAddr,
  • getServletPath,
  • getInputStream,
  • getParameterMap,
  • getCookies,
  • getServerName,
  • getHeaderNames,
  • getScheme,
  • getServerPort

Popular in Java

  • Making http requests using okhttp
  • setContentView (Activity)
  • runOnUiThread (Activity)
  • requestLocationUpdates (LocationManager)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now