List of usage examples for javax.servlet.http HttpServletResponse sendError
public void sendError(int sc, String msg) throws IOException;
Sends an error response to the client using the specified status and clears the buffer.
From source file:au.org.ala.biocache.web.AbstractSecureController.java
/** * Returns true when the operation should be performed. * @param apiKey//from ww w.j a v a 2s. co m * @param response * @return * @throws Exception */ public boolean shouldPerformOperation(String apiKey, HttpServletResponse response, boolean checkReadOnly) throws Exception { if (checkReadOnly && Store.isReadOnly()) { response.sendError(HttpServletResponse.SC_CONFLICT, "Server is in read only mode. Try again later."); } else if (apiKey == null || !isValidKey(apiKey)) { response.sendError(HttpServletResponse.SC_FORBIDDEN, "An invalid API Key was provided."); } return !response.isCommitted(); }
From source file:io.github.jhipster.security.Http401UnauthorizedEntryPoint.java
/** * Always returns a 401 error code to the client. *//*from w w w . j a v a 2 s.c om*/ @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException arg2) throws IOException, ServletException { log.debug("Pre-authenticated entry point called. Rejecting access"); response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Access Denied"); }
From source file:de.mpg.escidoc.services.pidcache.web.MainServlet.java
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "DELETE method not supported for this service."); }
From source file:de.mpg.escidoc.services.pidcache.web.MainServlet.java
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "PUT method not supported for this service"); }
From source file:com.cradiator.TeamCityStatusPlugin.BuildMonitorController.java
private ModelAndView showProject(String projectId, HttpServletResponse response) throws IOException { SProject project = projectManager.findProjectById(projectId); if (project == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "no project with id " + projectId); return null; }/*from w ww . j a v a 2 s .com*/ return modelWithView("project-status.jsp").addObject("project", new ProjectMonitorViewState(project)); }
From source file:org.owasp.webgoat.AjaxAuthenticationEntryPoint.java
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { if (request.getHeader("x-requested-with") != null) { response.sendError(401, authException.getMessage()); } else {//ww w . j a va 2s. c om super.commence(request, response, authException); } }
From source file:com.lennonjesus.auth.security.Http401UnauthorizedEntryPoint.java
/** * Always returns a 401 error code to the client. *///from w w w . j ava 2 s . c o m public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException arg2) throws IOException, ServletException { log.debug("Pre-authenticated entry point called. Rejecting access:" + request.getRequestURL()); response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Access Denied"); }
From source file:com.threewks.thundr.servlet.ServletExceptionViewResolver.java
protected void sendError(Throwable exceptionOfInterest, HttpServletResponse rawResponse) { try {/*from w w w. java2s. c o m*/ String message = exceptionOfInterest == null ? "" : StringUtils.trimToEmpty(exceptionOfInterest.getMessage()); rawResponse.sendError(StatusCode.InternalServerError.getCode(), message); } catch (IOException e) { throw new ViewResolutionException(e, "Failed to send error to client: %s", e.getMessage()); } }
From source file:com.cradiator.TeamCityStatusPlugin.BuildMonitorController.java
private ModelAndView showBuild(String buildTypeId, HttpServletResponse response) throws IOException { SBuildType buildType = projectManager.findBuildTypeById(buildTypeId); if (buildType == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "no buildType with id " + buildTypeId); return null; }/*from w ww . j a va 2 s. c o m*/ return modelWithView("build-status.jsp").addObject("build", new BuildTypeMonitorViewState(server, buildType)); }
From source file:com.ecyrd.jspwiki.dav.WikiDavServlet.java
@Override public void doCopy(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "JSPWiki is read-only."); }