List of usage examples for javax.servlet.http HttpServletResponse sendError
public void sendError(int sc) throws IOException;
From source file:com.pentagon.web.system.controller.MenuPermissionController.java
@RequestMapping(value = "/edit", method = RequestMethod.GET) public ModelAndView edit(HttpServletRequest request, HttpServletResponse response) throws IOException { String groupId = request.getParameter("groupId"); if (StringUtil.isBlank(groupId)) { response.sendError(403); return null; }// w w w. j a v a 2s .c o m MenuPermission group = menuService.selectByPrimaryKey(Long.valueOf(groupId)); ModelAndView mav = new ModelAndView("system/menuPermissionEdit"); mav.addObject("group", group); return mav; }
From source file:com.thinkberg.webdav.HeadHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { FileObject object = VFSBackend.resolveFile(request.getPathInfo()); if (object.exists()) { if (FileType.FOLDER.equals(object.getType())) { response.sendError(HttpServletResponse.SC_FORBIDDEN); } else {/*from www .j a v a2s.c o m*/ setHeader(response, object.getContent()); } } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.datatools.dumprestore.DumpRestoreController.java
@Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { if (!PolicyHelper.isAuthorizedForActions(req, REQUIRED_ACTION)) { resp.sendError(HttpServletResponse.SC_FORBIDDEN); }/*from w w w. j a va 2 s . com*/ try { if (ACTION_RESTORE.equals(req.getPathInfo())) { long tripleCount = new RestoreModelsAction(req, resp).restoreModels(); req.setAttribute(ATTRIBUTE_TRIPLE_COUNT, tripleCount); super.doGet(req, resp); } else { resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } } catch (BadRequestException | RDFServiceException e) { throw new RuntimeException(e); } }
From source file:com.enonic.cms.web.portal.PortalServlet.java
@Override protected void service(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException { final String requestMethod = req.getMethod(); if (!ALLOWED_HTTP_METHODS.contains(requestMethod)) { res.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); return;// ww w. ja v a 2 s . com } if (requestMethod.equals("OPTIONS")) { doOptions(req, res); return; } ServletRequestAccessor.setRequest(req); OriginalUrlResolver.resolveOriginalUrl(req); this.dispatcher.handle(req, res); }
From source file:it.marcoberri.mbfasturl.cron.QuartzInitServlet.java
/** * /*from w ww . ja va2s. co m*/ * @param request * @param response * @throws ServletException * @throws IOException */ @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.sendError(HttpServletResponse.SC_FORBIDDEN); }
From source file:it.marcoberri.mbfasturl.cron.QuartzInitServlet.java
/** * // w ww. j a v a2 s .com * @param request * @param response * @throws ServletException * @throws IOException */ @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.sendError(HttpServletResponse.SC_FORBIDDEN); }
From source file:javarestart.controllers.ApplicationController.java
@ResponseBody @RequestMapping(value = "/{applicationName}", method = RequestMethod.GET) public AppDescriptorDto getAppDescriptor(@PathVariable("applicationName") String applicationName, HttpServletResponse response) throws Exception { AppResourceProvider resourceProvider = getOrRegisterApp(applicationName); if (resourceProvider == null) { response.sendError(404); return null; }/*from w w w. j a v a2s .c o m*/ return resourceProvider.getAppDescriptor(); }
From source file:org.chimi.s4s.controller.FileDownloadController.java
private void checkAndSend(boolean requestImageInline, HttpServletRequest request, HttpServletResponse response, FileSource file) throws IOException { if (file == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return;// ww w . ja va 2 s. c o m } if (requestImageInline && !file.isImage()) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } if (checkModifiedRequest(request)) { response.setStatus(304); response.setContentType(file.getMimeType()); cacheStrategy.setCacheOption(file, response); return; } sendFile(requestImageInline, file, request, response); }
From source file:com.thinkberg.moxo.dav.HeadHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { FileObject object = getResourceManager().getFileObject(request.getPathInfo()); if (object.exists()) { if (FileType.FOLDER.equals(object.getType())) { response.sendError(HttpServletResponse.SC_FORBIDDEN); } else {/* w w w. ja v a 2s. com*/ setHeader(response, object.getContent()); } } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } }
From source file:waffle.spring.handlers.CustomAccessDeniedHandler.java
@Override public void handle(final HttpServletRequest request, final HttpServletResponse response, final AccessDeniedException ex) throws IOException, ServletException { // here we can add custom headers or response status, data or redirect response.addHeader("Custom-header", "some value"); response.sendError(HttpServletResponse.SC_UNAUTHORIZED); }