Example usage for javax.servlet.http HttpServletRequest getMethod

List of usage examples for javax.servlet.http HttpServletRequest getMethod

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getMethod.

Prototype

public String getMethod();

Source Link

Document

Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.

Usage

From source file:net.buffalo.service.BuffaloWorker.java

public void validate(HttpServletRequest request, HttpServletResponse response) throws ValidationException {
    if (!request.getMethod().equals("POST")) {
        throw new ValidationException("Buffalo worker support POST only!");
    }//  w  w w  .  j  av a 2s. co  m
}

From source file:net.sf.j2ep.requesthandlers.BasicRequestHandler.java

/**
 * Will only set the headers./*from  w  w  w .  ja  v a 2 s  .  co m*/
 * @throws HttpException 
 * 
 * @see net.sf.j2ep.model.RequestHandler#process(javax.servlet.http.HttpServletRequest, java.lang.String)
 */
public HttpMethod process(HttpServletRequest request, String url) throws HttpException {

    HttpMethodBase method = null;

    if (request.getMethod().equalsIgnoreCase("GET")) {
        method = new GetMethod(url);
    } else if (request.getMethod().equalsIgnoreCase("HEAD")) {
        method = new HeadMethod(url);
    } else if (request.getMethod().equalsIgnoreCase("DELETE")) {
        method = new DeleteMethod(url);
    } else {
        return null;
    }

    setHeaders(method, request);
    return method;
}

From source file:com.firstclarity.magnolia.study.blossom.sample.PurchaseComponent.java

@RequestMapping("/purchase")
public String handleRequest(@ModelAttribute Customer customer, HttpServletRequest request,
        HttpSession session) {/*from  w  ww  .  j a v a2  s . co  m*/
    if ("POST".equals(request.getMethod())) {

        ShoppingCart shoppingCart = ShoppingCart.getShoppingCart(session);

        List<OrderRow> rows = new ArrayList<OrderRow>();
        for (ShoppingCartItem cartItem : shoppingCart.getItems()) {
            rows.add(new OrderRow(cartItem.getProduct().getArticleCode(), cartItem.getQuantity()));
        }
        Order order = new Order(customer, rows);

        salesApplicationWebService.placeOrder(order);

        shoppingCart.clear();

        return "mymodule/components/purchaseFormSubmitted.jsp";
    }
    return "mymodule/components/purchaseForm.jsp";
}

From source file:net.big_oh.common.web.listener.request.ObservedHttpServletRequest.java

public ObservedHttpServletRequest(HttpServletRequest request) {
    super(request);

    httpMethod = request.getMethod();

    resourceRequested = request.getRequestURL().toString();

    queryString = request.getQueryString();

    contextName = request.getContextPath();

    containerUserName = request.getRemoteUser();

    HttpSession session = request.getSession(false);
    jSessionId = (session == null) ? null : session.getId();
}

From source file:org.alfresco.repo.lotus.server.QuickrServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    if (request.getMethod().equals("GET") && (request.getPathInfo().endsWith("/services/LibraryService")
            || request.getPathInfo().endsWith("/services/ContentService"))) {
        response.setStatus(HttpServletResponse.SC_OK);
        return;/*ww w.ja v  a  2 s. c o m*/
    }

    super.doGet(request, response);
}

From source file:org.italiangrid.storm.webdav.authz.CopyMoveAuthzVoter.java

private boolean isCopyOrMoveRequest(HttpServletRequest req) {

    final String method = req.getMethod();
    return (method.equals("COPY") || method.equals("MOVE"));

}

From source file:org.apereo.openlrs.model.error.XAPIErrorInfo.java

private void getDataFromRequest(final HttpServletRequest request) {
    this.path = request.getRequestURI();
    this.method = request.getMethod();
    this.parameters = request.getParameterMap();
}

From source file:photogift.server.filter.AuthenticatedFilter.java

private boolean noAuth(HttpServletRequest request) {
    String pathInfo = request.getPathInfo();
    String method = request.getMethod();
    return (pathInfo.startsWith("/giftchains") || (pathInfo.startsWith("/gifts/") && (method.equals("GET"))));
}

From source file:com.cisco.oss.foundation.http.server.HttpMethodFilter.java

@Override
public void doFilterImpl(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {

    HttpServletRequest httpServletRequest = (HttpServletRequest) request;

    String method = httpServletRequest.getMethod();
    if (methods.contains(method)) {
        LOGGER.error("method {} is not allowed", method);
        ((HttpServletResponse) response).sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
    } else {/*  w  ww.j  a va 2  s .c o  m*/
        chain.doFilter(request, response);
    }

}

From source file:net.sf.j2ep.requesthandlers.EntityEnclosingRequestHandler.java

/**
 * Will set the input stream and the Content-Type header to match this request.
 * Will also set the other headers send in the request.
 * /*from w  w  w . j  ava2 s .  co m*/
 * @throws IOException An exception is throws when there is a problem getting the input stream
 * @see net.sf.j2ep.model.RequestHandler#process(javax.servlet.http.HttpServletRequest, java.lang.String)
 */
public HttpMethod process(HttpServletRequest request, String url) throws IOException {

    EntityEnclosingMethod method = null;

    if (request.getMethod().equalsIgnoreCase("POST")) {
        method = new PostMethod(url);
    } else if (request.getMethod().equalsIgnoreCase("PUT")) {
        method = new PutMethod(url);
    }

    setHeaders(method, request);

    InputStreamRequestEntity stream;
    stream = new InputStreamRequestEntity(request.getInputStream());
    method.setRequestEntity(stream);
    method.setRequestHeader("Content-type", request.getContentType());

    return method;

}