List of usage examples for javax.servlet.http HttpServletResponse sendError
public void sendError(int sc) throws IOException;
From source file:com.platform.BRHTTPHelper.java
public static boolean handleError(int err, String errMess, Request baseRequest, HttpServletResponse resp) { try {// www . j a va 2 s . c o m baseRequest.setHandled(true); if (Utils.isNullOrEmpty(errMess)) resp.sendError(err); else resp.sendError(err, errMess); } catch (IOException e) { e.printStackTrace(); } return true; }
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 . ja v a2s .c o m*/ } writeFileInResponse(response, filePath, MediaType.APPLICATION_OCTET_STREAM_VALUE, "attachment"); }
From source file:org.bonitasoft.web.designer.controller.utils.HttpFile.java
public static void writeFileInResponse(HttpServletRequest request, HttpServletResponse response, Path filePath) throws IOException { if (!isExistingFilePath(response, filePath)) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return;/* w ww. ja v a 2 s.co m*/ } writeFileInResponse(response, filePath, request.getServletContext().getMimeType(filePath.getFileName().toString()), "inline"); }
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;//from ww w. j av a2 s . co 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:org.sloth.util.ControllerUtils.java
/** * This is a convenient method to send an 403-error to the client. * // w w w . ja v a2s.c o m * @param r * the {@code HttpServletResponse} * @return the view * @throws IOException * If an input or output exception occurs */ public static String forbiddenView(HttpServletResponse r) throws IOException { r.sendError(SC_FORBIDDEN); return UNAUTHORIZED_VIEW; }
From source file:org.sloth.util.ControllerUtils.java
/** * This is a convenient method to send an 500-error to the client. * //from w w w. ja v a2 s .c o m * @param r * the {@code HttpServletResponse} * @return the view * @throws IOException * If an input or output exception occurs */ public static String internalErrorView(HttpServletResponse r) throws IOException { r.sendError(SC_INTERNAL_SERVER_ERROR); return UNEXPECTED_ERROR_VIEW; }
From source file:org.sloth.util.ControllerUtils.java
/** * This is a convenient method to send an 404-error to the client. * // ww w . j a va2s . com * @param r * the {@code HttpServletResponse} * @return the view * @throws IOException * If an input or output exception occurs */ public static String notFoundView(HttpServletResponse r) throws IOException { r.sendError(SC_NOT_FOUND); return NOT_FOUND_VIEW; }
From source file:br.eb.ime.pfc.domain.GeoServerCommunication.java
private static void sendError(HTTP_STATUS status, HttpServletResponse response) { try (Writer writer = response.getWriter()) { response.sendError(status.getCode()); } catch (IOException e) { }//w w w . j a va2 s . c om }
From source file:com.adito.security.AbstractHTTPAuthenticationModule.java
/** * @param request/*from w ww.jav a2s .c o m*/ * @param response * @param realm * @throws IOException */ public static void sendAuthorizationError(HttpServletRequest request, HttpServletResponse response, String realm) throws IOException { if (log.isInfoEnabled()) log.info("Sending auth request for realm " + realm); response.setHeader("WWW-Authenticate", "Basic realm=\"" + realm + "\""); response.sendError(HttpServletResponse.SC_UNAUTHORIZED); request.getSession().setAttribute(Constants.AUTH_SENT, Boolean.TRUE); }
From source file:de.iteratec.iteraplan.presentation.ajax.DojoUtils.java
/** * Sets the response status to source not found * /*w w w.ja va 2 s .c om*/ * @param response */ public static void doNotFoundResponse(HttpServletResponse response) throws IOException { response.sendError(HttpServletResponse.SC_NOT_FOUND); }