List of usage examples for javax.servlet.http HttpServletResponse sendError
public void sendError(int sc) throws IOException;
From source file:net.longfalcon.web.WebExceptionHandlerResolver.java
private ModelAndView handleNoSuchResource(NoSuchResourceException ex, HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { response.sendError(HttpServletResponse.SC_NOT_FOUND); _log.error(ex, ex);//from w w w . j a va2 s .c om return new ModelAndView(); }
From source file:net.longfalcon.web.WebExceptionHandlerResolver.java
private ModelAndView handlePermissionDenied(PermissionDeniedException ex, HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED); _log.error(ex, ex);/* ww w . j a v a 2 s . c o m*/ return new ModelAndView(); }
From source file:net.longfalcon.web.WebExceptionHandlerResolver.java
private ModelAndView handleFlagrantSystemError(FlagrantSystemException ex, HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); _log.error(ex, ex);/*from w ww . j a v a 2 s . com*/ return new ModelAndView(); }
From source file:net.longfalcon.web.WebExceptionHandlerResolver.java
/** * Handle the case where an {@linkplain ModelAttribute @ModelAttribute} method * argument has binding or validation errors and is not followed by another * method argument of type {@link BindingResult}. * By default an HTTP 400 error is sent back to the client. * @param request current HTTP request//from w w w . j av a 2s. c o m * @param response current HTTP response * @param handler the executed handler * @return an empty ModelAndView indicating the exception was handled * @throws IOException potentially thrown from response.sendError() */ protected ModelAndView handleBindException(BindException ex, HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { response.sendError(HttpServletResponse.SC_BAD_REQUEST); _log.error(ex, ex); return new ModelAndView(); }
From source file:com.intuit.tank.util.RestSecurityFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (config.isRestSecurityEnabled()) { User user = getUser((HttpServletRequest) request); if (user == null) { // send 401 unauthorized and return HttpServletResponse resp = (HttpServletResponse) response; resp.sendError(HttpServletResponse.SC_UNAUTHORIZED); return; // break filter chain, requested JSP/servlet will not be executed }//from w w w. j a v a 2 s . c o m } chain.doFilter(request, response); }
From source file:edu.cornell.mannlib.vivo.orcid.controller.OrcidIntegrationController.java
private void show404NotFound(HttpServletResponse resp) throws IOException { resp.sendError(SC_NOT_FOUND); }
From source file:com.facebook.tsdb.tsdash.server.TsdbServlet.java
@Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.sendError(HttpServletResponse.SC_BAD_REQUEST); }
From source file:eu.forgestore.ws.util.AjaxUserFilter.java
@Override protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception { HttpServletRequest req = WebUtils.toHttp(request); logger.info("=======> AjaxUserFilter:onAccessDenied <============= MEethod = " + req.getMethod()); if (req.getMethod().equals("OPTIONS")) { //useful to pass CORS Options //usually for most browsers in OPTIONS there is no JSESSION ID cookie, //therefore there is a problem with the authentication //still bypassing the OPTIONS here seams not an authorization problem return true; }/*ww w .j a v a2s . com*/ String xmlHttpRequest = req.getHeader("X-Requested-With"); if (xmlHttpRequest != null) { if (xmlHttpRequest.equalsIgnoreCase("XMLHttpRequest")) { HttpServletResponse res = WebUtils.toHttp(response); res.sendError(401); return false; } logger.info( "=======> AjaxUserFilter:onAccessDenied xmlHttpRequest X-Requested-With=" + xmlHttpRequest); } HttpServletResponse res = WebUtils.toHttp(response); res.sendError(401); // xmlHttpRequest = req.getHeader("Origin"); //USED FOR CORS support on 401 error // if ( xmlHttpRequest != null ){ // res.addHeader("Access-Control-Allow-Origin", xmlHttpRequest); // res.addHeader("Access-Control-Allow-Credentials", "true"); // // logger.info("=======> AjaxUserFilter:onAccessDenied xmlHttpRequest Origin="+xmlHttpRequest); // // } return false; //return super.onAccessDenied(request, response); }
From source file:com.roche.iceboar.demo.JnlpServlet.java
private void error(HttpServletResponse response, String message) throws IOException { System.out.println(message);/* ww w . j av a 2 s. c om*/ response.sendError(404); }
From source file:com.bt.aloha.batchtest.ultramonkey.Servlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.sendError(HttpServletResponse.SC_BAD_REQUEST); }