Example usage for javax.servlet.http HttpServletResponse sendError

List of usage examples for javax.servlet.http HttpServletResponse sendError

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse sendError.

Prototype

public void sendError(int sc) throws IOException;

Source Link

Document

Sends an error response to the client using the specified status code and clears the buffer.

Usage

From source file:org.wallride.web.controller.admin.tag.TagSelect2Controller.java

@RequestMapping(value = "/{language}/tags/select/{id}", method = RequestMethod.GET)
public @ResponseBody DomainObjectSelect2Model select(@PathVariable String language, @PathVariable Long id,
        HttpServletResponse response) throws IOException {
    Tag tag = tagService.getTagById(id, language);
    if (tag == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return null;
    }/* w w  w .jav  a2 s . co m*/

    DomainObjectSelect2Model model = new DomainObjectSelect2Model(tag.getName(), tag.getName());
    return model;
}

From source file:com.thinkberg.moxo.dav.MkColHandler.java

public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
    if (request.getReader().readLine() != null) {
        response.sendError(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
        return;/*from  ww w .j a v  a  2 s  .c  o  m*/
    }

    FileObject object = getResourceManager().getFileObject(request.getPathInfo());

    try {
        LockManager.getInstance().checkCondition(object, getIf(request));
    } catch (LockException e) {
        if (e.getLocks() != null) {
            response.sendError(SC_LOCKED);
        } else {
            response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
        }
        return;
    }

    if (object.exists()) {
        response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
        return;
    }

    if (!object.getParent().exists() || !FileType.FOLDER.equals(object.getParent().getType())) {
        response.sendError(HttpServletResponse.SC_CONFLICT);
        return;
    }

    try {
        object.createFolder();
        response.setStatus(HttpServletResponse.SC_CREATED);
    } catch (FileSystemException e) {
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
    }
}

From source file:com.google.testing.testify.risk.frontend.server.api.impl.UploadApiImpl.java

private void error(HttpServletResponse resp, String errorText) throws IOException {
    resp.getOutputStream().print(errorText);
    resp.sendError(500);
    return;/*from w w w .  j  av  a2s .  c  o  m*/
}

From source file:com.ocpsoft.pretty.faces.application.PrettyRedirector.java

public void send404(final FacesContext facesContext) {
    try {/*from ww w  .j av  a2s  .co  m*/
        HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
    } catch (IOException e) {
        throw new PrettyException(e);
    }
}

From source file:org.apache.hadoop.gateway.dispatch.AbstractGatewayDispatch.java

public void doGet(URI url, HttpServletRequest request, HttpServletResponse response)
        throws IOException, URISyntaxException {
    response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
}

From source file:org.apache.hadoop.gateway.dispatch.AbstractGatewayDispatch.java

public void doPost(URI url, HttpServletRequest request, HttpServletResponse response)
        throws IOException, URISyntaxException {
    response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
}

From source file:org.apache.hadoop.gateway.dispatch.AbstractGatewayDispatch.java

public void doPut(URI url, HttpServletRequest request, HttpServletResponse response)
        throws IOException, URISyntaxException {
    response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
}

From source file:org.apache.hadoop.gateway.dispatch.AbstractGatewayDispatch.java

public void doDelete(URI url, HttpServletRequest request, HttpServletResponse response)
        throws IOException, URISyntaxException {
    response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
}

From source file:org.apache.hadoop.gateway.dispatch.AbstractGatewayDispatch.java

public void doOptions(URI url, HttpServletRequest request, HttpServletResponse response)
        throws IOException, URISyntaxException {
    response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
}

From source file:org.wallride.web.controller.admin.post.PostSelectController.java

@RequestMapping(value = "/{language}/posts/select/{id}")
public @ResponseBody DomainObjectSelect2Model select(@PathVariable String language, @RequestParam Long id,
        HttpServletResponse response) throws IOException {
    Post post = postService.getPostById(id, language);
    if (post == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return null;
    }//  ww  w.j a v a2 s  .com

    DomainObjectSelect2Model model = new DomainObjectSelect2Model(post);
    return model;
}