List of usage examples for javax.servlet.http HttpServletResponse setStatus
public void setStatus(int sc);
From source file:cz.cas.lib.proarc.authentication.utils.AuthUtils.java
/** * Writes the authentication OK status to the HTTP response. * @param response response//from www . j a va2 s . c o m * @throws IOException failure * @see <a href='http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/docs/Relogin.html'>SmartGWT Relogin</a> */ public static void setLoginSuccesResponse(HttpServletResponse response) throws IOException { response.setStatus(HttpServletResponse.SC_OK); response.setContentType(MediaType.TEXT_HTML); InputStream res = ProarcAuthFilter.class.getResourceAsStream("loginSuccessMarker.html"); try { IOUtils.copy(res, response.getOutputStream()); res.close(); } finally { IOUtils.closeQuietly(res); } }
From source file:com.intbit.util.ServletUtil.java
public static void printIllegalArgumentError(HttpServletResponse response, String errorMsg) throws IOException { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); Map<String, Object> error = new HashMap<>(); error.put("error", errorMsg); response.getWriter().write(AppConstants.GSON.toJson(error)); response.getWriter().flush();//from w w w. j a va 2 s. c om }
From source file:com.intbit.util.ServletUtil.java
public static void printInternalException(HttpServletResponse response, String errorMsg) throws IOException { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Map<String, Object> errorMap = new HashMap<>(); errorMap.put("error", errorMsg); response.getWriter().write(AppConstants.GSON.toJson(errorMap)); response.getWriter().flush();//ww w . j a v a 2s. com }
From source file:jp.go.nict.langrid.foundation.servlet.ResponseProcessor.java
private static void addFaultHeader(HttpServletResponse response) { response.setStatus(500); response.setContentType("text/xml; charset=utf-8"); response.setHeader("Server", "LanguageGrid-CoreNode/1.0"); response.setDateHeader("Date", new Date().getTime()); }
From source file:com.intbit.util.ServletUtil.java
public static void printSuccessData(HttpServletResponse response, Map<String, Object> data) throws IOException { response.setStatus(HttpServletResponse.SC_OK); response.getWriter().write(AppConstants.GSON.toJson(data)); response.getWriter().flush();//from w ww .j a v a 2 s .c o m }
From source file:com.platform.BRHTTPHelper.java
public static boolean handleSuccess(int code, byte[] body, Request baseRequest, HttpServletResponse resp, String contentType) {//from w ww .j a v a 2s . c om try { resp.setStatus(code); if (contentType != null && !contentType.isEmpty()) resp.setContentType(contentType); if (body != null) resp.getOutputStream().write(body); baseRequest.setHandled(true); } catch (IOException e) { e.printStackTrace(); } return true; }
From source file:com.intbit.util.ServletUtil.java
public static void printIllegalArgumentError(HttpServletResponse response, List<String> errorMsgs) throws IOException { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); Map<String, Object> error = new HashMap<>(); error.put("error", errorMsgs); response.getWriter().write(AppConstants.GSON.toJson(error)); response.getWriter().flush();/*from ww w . ja v a 2 s .com*/ }
From source file:com.google.caja.ancillary.servlet.UploadPage.java
private static void writeHeader(HttpServletResponse resp) throws IOException { resp.setStatus(200); resp.setContentType("text/html;charset=UTF-8"); Writer out = resp.getWriter(); out.write("<h1>Loading…</h1>"); out.flush();//from w w w . j av a 2 s . com }
From source file:nl.dtls.fairdatapoint.api.controller.utils.HttpHeadersUtils.java
/** * Set response header for the successful call * /*from w ww .j av a 2 s.c o m*/ * @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:nl.dtls.fairdatapoint.api.controller.utils.HttpHeadersUtils.java
/** * Set response header for the internal server errors * // ww w.j a va 2s .co m * @param response Http response * @param ex Server exception * @return returns null (as a response body) */ public static String set500ResponseHeaders(HttpServletResponse response, Exception ex) { String errorMessage = ("Internal server error; Error message : " + ex.getMessage()); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); try { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, errorMessage); } catch (IOException ex1) { LOGGER.warn( "Error setting error message for internal server " + "error; The error : " + ex1.getMessage()); } response.setContentType(MediaType.TEXT_PLAIN_VALUE); return null; }