Example usage for javax.servlet.http HttpServletResponse SC_NOT_FOUND

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

Introduction

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

Prototype

int SC_NOT_FOUND

To view the source code for javax.servlet.http HttpServletResponse SC_NOT_FOUND.

Click Source Link

Document

Status code (404) indicating that the requested resource is not available.

Usage

From source file:org.bonitasoft.web.designer.controller.utils.HttpFile.java

public static void writeFileInResponseForVisualization(HttpServletRequest request, HttpServletResponse response,
        Path filePath) throws IOException {
    if (!isExistingFilePath(response, filePath)) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return;// w  w  w.  j  ava  2 s  . c  o  m
    }
    String mimeType = request.getServletContext().getMimeType(filePath.getFileName().toString());
    if (mimeType == null || !mimeType.contains("image")) {
        mimeType = MediaType.TEXT_PLAIN_VALUE;
    }
    writeFileInResponse(response, filePath, mimeType, "inline");
}

From source file:com.carolinarollergirls.scoreboard.jetty.StreamServlet.java

protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    super.doPost(request, response);

    response.sendError(HttpServletResponse.SC_NOT_FOUND);
}

From source file:io.hawt.testing.env.builtin.NotFound.java

@Override
public void handle(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
    resp.setContentType("application/json");
    resp.setCharacterEncoding("UTF-8");
    JSONObject r = new JSONObject();
    r.put("error", HttpServletResponse.SC_NOT_FOUND);
    r.put("message", "Environment not found");
    resp.getWriter().println(r.toJSONString());
    resp.getWriter().close();//  w w w .j a v a 2  s .com
}

From source file:com.graphhopper.http.InvalidRequestServlet.java

@Override
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    res.setStatus(HttpServletResponse.SC_NOT_FOUND);
    res.setContentType("text/plain");
    res.setContentType("UTF-8");
    JSONObject json = new JSONObject();
    json.put("error_code", "404");
    writeJson(req, res, json);//  ww w. jav  a 2  s.  co  m
}

From source file:org.bonitasoft.web.designer.controller.utils.HttpFile.java

public static void writeFileInResponseForDownload(HttpServletResponse response, Path filePath)
        throws IOException {
    if (!isExistingFilePath(response, filePath)) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
        return;//from   w ww .  j  a v  a2s  .c o  m
    }
    writeFileInResponse(response, filePath, MediaType.APPLICATION_OCTET_STREAM_VALUE, "attachment");
}

From source file:nl.dtls.fairdatapoint.api.controller.utils.HttpHeadersUtils.java

/**
 * Set response header for the successful call
 * /*  ww  w .  j  a v a  2  s . com*/
 * @param responseBody ResponseBody
 * @param response  Http response
 * @param requesetedContentType Requeseted ContentType(i.e Accept header)
 */
public static void set200ResponseHeaders(String responseBody, HttpServletResponse response,
        RDFFormat requesetedContentType) {
    if (responseBody == null) {
        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
        response.setContentType(MediaType.TEXT_PLAIN_VALUE);
    } else {
        response.setStatus(HttpServletResponse.SC_OK);
        response.setContentType(requesetedContentType.getDefaultMIMEType());
    }
}

From source file:com.carolinarollergirls.scoreboard.jetty.LoadXmlScoreBoard.java

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    super.doGet(request, response);
    response.sendError(HttpServletResponse.SC_NOT_FOUND);
}

From source file:com.web.vehiclerouting.graphhopper.http.InvalidRequestServlet.java

@Override
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    try {/*from  w  w  w. ja v a2  s .  c  om*/
        res.setStatus(HttpServletResponse.SC_NOT_FOUND);
        res.setContentType("text/plain");
        res.setContentType("UTF-8");
        JSONObject json = new JSONObject();
        json.put("error_code", "404");
        writeJson(req, res, json);
    } catch (JSONException ex) {
        Logger.getLogger(InvalidRequestServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.liferay.portal.servlet.DisplayChartServlet.java

@Override
public void service(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

    try {/*from   w  ww.j  a  v a2  s. co m*/
        super.service(request, response);
    } catch (Exception e) {
        PortalUtil.sendError(HttpServletResponse.SC_NOT_FOUND, e, request, response);
    }
}

From source file:com.tamnd.app.config.security.AuthFailure.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    if (exception instanceof BadCredentialsException) {
        response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    } else if (exception instanceof UsernameNotFoundException) {
        response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    } else {//from www. java 2 s  .  c o  m
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    }
}