List of usage examples for javax.servlet.http HttpServletResponse SC_NOT_FOUND
int SC_NOT_FOUND
To view the source code for javax.servlet.http HttpServletResponse SC_NOT_FOUND.
Click Source Link
From source file:controller.MunicipiosRestController.java
/** * * @param id//from w ww. j av a 2 s . c om * @param request * @param response * @return JSON */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") public String getByIdJSON(@PathVariable("id") int id, HttpServletRequest request, HttpServletResponse response) { MunicipiosDAO tabla = new MunicipiosDAO(); Gson JSON; Municipios elemento; try { elemento = tabla.selectById(id); if (elemento == null) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existe el elemeto solicitado con id:" + id); JSON = new Gson(); return JSON.toJson(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServerError", ex.getMessage()); JSON = new Gson(); return JSON.toJson(e); } JSON = new Gson(); response.setStatus(HttpServletResponse.SC_OK); return JSON.toJson(elemento); }
From source file:controller.IndicadoresRestController.java
/** * * @param id/*from w w w. jav a 2 s .c o m*/ * @param request * @param response * @return JSON */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") public String getByIdJSON(@PathVariable("id") String id, HttpServletRequest request, HttpServletResponse response) { IndicadoresDAO tabla = new IndicadoresDAO(); Gson JSON; Indicadores elemento; try { elemento = tabla.selectById(id); if (elemento == null) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existe el elemeto solicitado con id:" + id); JSON = new Gson(); return JSON.toJson(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServerError", ex.getMessage()); JSON = new Gson(); return JSON.toJson(e); } JSON = new Gson(); response.setStatus(HttpServletResponse.SC_OK); return JSON.toJson(elemento); }
From source file:jp.terasoluna.fw.web.struts.actions.ReloadCodeListAction.java
/** * LbVR?[hXg???B//w w w . j a va 2 s. c om * * <p> * ???s?A? parameter ?w?tH??[h?B * parameter ?w?AcodeListLoader??? * SC_NOT_FOUND?i404?j G?[?B * </p> * * @param mapping ANV}bsO * @param form ANVtH?[ * @param req HTTPNGXg * @param res HTTPX|X * @return parameter ?wJ?? */ @Override public ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) { if (log.isDebugEnabled()) { log.debug("doExecute() called."); } if (codeListLoader != null) { codeListLoader.reload(); } String path = mapping.getParameter(); if (path == null) { // p??[^?????A?i404?jG?[p?B try { res.sendError(HttpServletResponse.SC_NOT_FOUND); } catch (IOException e) { log.error("Error page(404) forwarding failed."); throw new SystemException(e, FORWARD_ERRORPAGE_ERROR); } return null; } return new ActionForward(path); }
From source file:controller.TemasNivel2RestController.java
/** * * @param id/* w w w .j av a 2 s. c o m*/ * @param request * @param response * @return JSON */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") public String getByIdJSON(@PathVariable("id") int id, HttpServletRequest request, HttpServletResponse response) { TemasNivel2DAO tabla = new TemasNivel2DAO(); Gson JSON; TemasNivel2 elemento; try { elemento = tabla.selectById(id); if (elemento == null) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existe el elemeto solicitado con id:" + id); JSON = new Gson(); return JSON.toJson(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServerError", ex.getMessage()); JSON = new Gson(); return JSON.toJson(e); } JSON = new Gson(); response.setStatus(HttpServletResponse.SC_OK); return JSON.toJson(elemento); }
From source file:controller.TemasNivel1RestController.java
/** * * @param id// ww w . ja va 2s. c om * @param request * @param response * @return JSON */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") public String getByIdJSON(@PathVariable("id") int id, HttpServletRequest request, HttpServletResponse response) { TemasNivel1DAO tabla = new TemasNivel1DAO(); Gson JSON; TemasNivel1 elemento; try { elemento = tabla.selectById(id); if (elemento == null) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existe el elemeto solicitado con id:" + id); JSON = new Gson(); return JSON.toJson(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServerError", ex.getMessage()); JSON = new Gson(); return JSON.toJson(e); } JSON = new Gson(); response.setStatus(HttpServletResponse.SC_OK); return JSON.toJson(elemento); }
From source file:at.gv.egiz.bku.online.webapp.UIServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { BindingProcessorManager bindingProcessorManager = (BindingProcessorManager) getServletContext() .getAttribute("bindingProcessorManager"); if (bindingProcessorManager == null) { String msg = "Configuration error: BindingProcessorManager missing!"; log.error(msg);//from w ww . j av a 2 s . c om resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg); return; } Configuration conf = ((BindingProcessorManagerImpl) bindingProcessorManager).getConfiguration(); if (conf == null) log.error("No configuration"); else MoccaParameterBean.setP3PHeader(conf, resp); Id id = (Id) req.getAttribute("id"); BindingProcessor bindingProcessor = null; if (id == null || !((bindingProcessor = bindingProcessorManager .getBindingProcessor(id)) instanceof HTTPBindingProcessor)) { resp.sendRedirect(expiredPageUrl); return; } MoccaParameterBean parameterBean = new MoccaParameterBean((HTTPBindingProcessor) bindingProcessor); req.setAttribute("moccaParam", parameterBean); String uiPage = MoccaParameterBean.getInitParameter("uiPage", getServletConfig(), getServletContext()); uiPage = parameterBean.getUIPage(uiPage); if (uiPage == null) { uiPage = "applet.jsp"; } RequestDispatcher dispatcher = req.getRequestDispatcher(uiPage); if (dispatcher == null) { log.warn("Failed to get RequestDispatcher for page {}.", uiPage); resp.sendError(HttpServletResponse.SC_NOT_FOUND); } else { dispatcher.forward(req, resp); } }
From source file:controller.TemasNivel3RestController.java
/** * * @param id/*from ww w .j a va 2s . c o m*/ * @param request * @param response * @return JSON */ @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json") public String getByIdJSON(@PathVariable("id") int id, HttpServletRequest request, HttpServletResponse response) { TemasNivel3DAO tabla = new TemasNivel3DAO(); Gson JSON; TemasNivel3 elemento; try { elemento = tabla.selectById(id); if (elemento == null) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existe el elemeto solicitado con id:" + id); JSON = new Gson(); return JSON.toJson(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServerError", ex.getMessage()); JSON = new Gson(); return JSON.toJson(e); } JSON = new Gson(); response.setStatus(HttpServletResponse.SC_OK); return JSON.toJson(elemento); }
From source file:org.shredzone.cilla.view.HeaderView.java
/** * Streams the header image.//from w w w .j av a 2s . co m */ @View(pattern = "/header/image/${header.id}-${#type}.${#suffix(header.headerImage.contentType)}") @View(pattern = "/header/image/${header.id}.${#suffix(header.headerImage.contentType)}") public void headerImageView(@PathPart("header.id") Header header, @Optional @PathPart("#type") String type, HttpServletRequest req, HttpServletResponse resp) throws ViewException, CillaServiceException { if (!headerService.isVisible(header)) { throw new ErrorResponseException(HttpServletResponse.SC_FORBIDDEN); } ImageProcessing ip = null; if (type != null) { ip = imageProcessingManager.createImageProcessing(type); if (ip == null) { throw new ErrorResponseException(HttpServletResponse.SC_NOT_FOUND); } } ResourceDataSource ds = headerService.getHeaderImage(header, ip); streamDataSource(ds, req, resp); }
From source file:gov.lanl.adore.djatoka.openurl.OpenURLJP2Ping.java
/** * Returns the OpenURLResponse of a JSON object defining image status. Status Codes: *//*w w w.j av a 2s. co m*/ @Override public OpenURLResponse resolve(final ServiceType serviceType, final ContextObject contextObject, final OpenURLRequest openURLRequest, final OpenURLRequestProcessor processor) { final String responseFormat = RESPONSE_TYPE; int status = HttpServletResponse.SC_NOT_FOUND; byte[] bytes = new byte[] {}; try { final String id = ((URI) contextObject.getReferent().getDescriptors()[0]).toASCIIString(); status = ReferentManager.getResolver().getStatus(id); if (status != HttpServletResponse.SC_NOT_FOUND) { final ObjectMapper mapper = new ObjectMapper(); final ObjectNode rootNode = mapper.createObjectNode(); String res_status = null; if (status == HttpServletResponse.SC_OK) { res_status = STATUS_OK; } else if (status == HttpServletResponse.SC_ACCEPTED) { res_status = STATUS_ACCEPTED; } rootNode.put("identifier", id); rootNode.put("status", res_status); bytes = mapper.writeValueAsBytes(rootNode); } } catch (final Exception e) { LOGGER.error(e.getMessage(), e); status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; } final HashMap<String, String> header_map = new HashMap<String, String>(); header_map.put("Content-Length", Integer.toString(bytes.length)); header_map.put("Date", HttpDate.getHttpDate()); return new OpenURLResponse(status, responseFormat, bytes, header_map); }
From source file:ru.mystamps.web.controller.CategoryController.java
@GetMapping(Url.INFO_CATEGORY_BY_ID_PAGE) public View showInfoById(@Category @PathVariable("slug") LinkEntityDto country, HttpServletResponse response) throws IOException { if (country == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return null; }// w ww . j a v a 2 s . c om RedirectView view = new RedirectView(); view.setStatusCode(HttpStatus.MOVED_PERMANENTLY); view.setUrl(Url.INFO_CATEGORY_PAGE); return view; }