List of usage examples for javax.servlet.http HttpServletResponse sendError
public void sendError(int sc) throws IOException;
From source file:net.sourceforge.subsonic.controller.AvatarController.java
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { Avatar avatar = getAvatar(request);/* w w w .ja v a2 s.co m*/ if (avatar == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; } response.setContentType(avatar.getMimeType()); response.getOutputStream().write(avatar.getData()); return null; }
From source file:com.mirth.connect.server.servlets.UsageServlet.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try {// w ww.j a v a 2 s .c om if (!isUserLoggedIn(request)) { response.sendError(HttpServletResponse.SC_FORBIDDEN); } else { PrintWriter out = response.getWriter(); ObjectXMLSerializer serializer = ObjectXMLSerializer.getInstance(); Operation operation = Operations.getOperation(request.getParameter("op")); UsageController usageController = ControllerFactory.getFactory().createUsageController(); if (operation.equals(Operations.USAGE_DATA_GET)) { response.setContentType(TEXT_PLAIN); if (isUserAuthorized(request, null)) { serializer.serialize(usageController.createUsageStats(true), out); } else { response.sendError(HttpServletResponse.SC_UNAUTHORIZED); } } } } catch (RuntimeIOException rio) { logger.debug(rio); } catch (Throwable t) { logger.debug(ExceptionUtils.getStackTrace(t)); throw new ServletException(t); } }
From source file:ar.com.zauber.commons.spring.web.controllers.AbstractRestishController.java
/** called when no method is found. desing for override */ protected ModelAndView onMethodFound(final HttpServletRequest request, final HttpServletResponse response) throws Exception { response.sendError(404); return null;/*from www . ja va 2 s . c o m*/ }
From source file:it.marcoberri.mbmeteo.action.UploadFile.java
/** * Handles the HTTP//from ww w . ja va2 s. com * <code>GET</code> method. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.sendError(HttpServletResponse.SC_FORBIDDEN); }
From source file:ru.mystamps.web.controller.CollectionController.java
@GetMapping(Url.INFO_COLLECTION_BY_ID_PAGE) public View showInfoById(@PathVariable("slug") String slug, HttpServletResponse response) throws IOException { if (slug == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; }/*from www . j av a2 s. c o m*/ CollectionInfoDto collection = collectionService.findBySlug(slug); if (collection == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; } RedirectView view = new RedirectView(); view.setStatusCode(HttpStatus.MOVED_PERMANENTLY); view.setUrl(Url.INFO_COLLECTION_PAGE); return view; }
From source file:fr.mael.microrss.web.LoginEntryPoint.java
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { if (isAjaxAndException(request, authException)) { response.sendError(HttpServletResponse.SC_UNAUTHORIZED); } else {/*from ww w . j a va2 s. co m*/ super.commence(request, response, authException); } }
From source file:org.wallride.web.controller.admin.category.CategorySelectController.java
@RequestMapping(value = "/{language}/categories/select/{id}", method = RequestMethod.GET) public @ResponseBody DomainObjectSelect2Model select(@PathVariable String language, @PathVariable Long id, HttpServletResponse response) throws IOException { Category category = categoryService.getCategoryById(id, language); if (category == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; }//from www. j a va 2 s . co m DomainObjectSelect2Model model = new DomainObjectSelect2Model(category.getId(), category.getName()); return model; }
From source file:org.openmrs.module.openhmis.cashier.web.controller.ReceiptController.java
@RequestMapping(method = RequestMethod.GET) public void get(@RequestParam(value = "billId", required = false) Integer billId, HttpServletResponse response) throws IOException { if (billId == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return;/*from www . j av a 2 s . c o m*/ } IBillService service = Context.getService(IBillService.class); Bill bill = service.getById(billId); if (!validateBill(billId, bill, response)) { return; } JasperReport report = ModuleSettings.getReceiptReport(); if (report == null) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Configuration error: need to specify global " + "option for default report ID."); return; } if (generateReport(billId, response, bill, report)) { bill.setReceiptPrinted(true); service.save(bill); } }
From source file:ru.mystamps.web.controller.CategoryController.java
@GetMapping(Url.INFO_CATEGORY_PAGE) public String showInfoBySlug(@Category @PathVariable("slug") LinkEntityDto category, Model model, Locale userLocale, HttpServletResponse response) throws IOException { if (category == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; }/* w w w . j av a2s. co m*/ String slug = category.getSlug(); String name = category.getName(); String lang = LocaleUtils.getLanguageOrNull(userLocale); List<SeriesInfoDto> series = seriesService.findByCategorySlug(slug, lang); model.addAttribute("categorySlug", slug); model.addAttribute("categoryName", name); model.addAttribute("seriesOfCategory", series); return "category/info"; }
From source file:ru.mystamps.web.controller.CountryController.java
@GetMapping(Url.INFO_COUNTRY_PAGE) public String showInfoBySlug(@Country @PathVariable("slug") LinkEntityDto country, Model model, Locale userLocale, HttpServletResponse response) throws IOException { if (country == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; }/*from w w w . j a v a 2 s.c o m*/ String slug = country.getSlug(); String name = country.getName(); String lang = LocaleUtils.getLanguageOrNull(userLocale); List<SeriesInfoDto> series = seriesService.findByCountrySlug(slug, lang); model.addAttribute("countrySlug", slug); model.addAttribute("countryName", name); model.addAttribute("seriesOfCountry", series); return "country/info"; }