List of usage examples for javax.servlet.http HttpServletResponse SC_INTERNAL_SERVER_ERROR
int SC_INTERNAL_SERVER_ERROR
To view the source code for javax.servlet.http HttpServletResponse SC_INTERNAL_SERVER_ERROR.
Click Source Link
From source file:org.tec.security.spring.AuthenticationSuccess.java
/** * {@inheritDoc}// w ww.j a va 2 s . c o m */ @Override() public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { ControllerUtils.clearCurrentUser(request.getSession()); if (mLogger.isDebugEnabled()) { mLogger.debug("succeful login for " + request.getParameter("j_username")); } Writer out = response.getWriter(); try { out.write("{success:true}"); } catch (IOException e) { mLogger.error("failed to write to response", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "processing failed"); } finally { out.close(); } }
From source file:com.iflytek.edu.cloud.frame.spring.OAuth2AuthenticationEntryPointExt.java
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { if (authException.getCause() instanceof InvalidTokenException) { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); MainError mainError = MainErrors.getError(MainErrorType.INVALID_ACCESS_TOKEN, (Locale) request.getAttribute("locale")); messageConverter.convertData(request, response, mainError); } else {/*from www . j a va2s . c om*/ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); doHandle(request, response, authException); } }
From source file:com.sg.rest.ExceptionHandlingTest.java
@Test public void testExceptionDuringServiceCall() throws Exception { mockMvc.perform(get(RequestPath.TEST_REQUEST_THROW_EXCEPTION)) .andExpect(status().is(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)) .andExpect(content().contentType(CustomMediaTypes.APPLICATION_JSON_UTF8.getMediatype())) .andExpect(jsonPath("$.eventRef.id", not(isEmptyOrNullString()))); }
From source file:no.dusken.momus.exceptions.ExceptionHandler.java
@Override public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse response, Object o, Exception e) { if (e instanceof RestException) { // If it's our exception, we know how to handle it and has set a status response.setStatus(((RestException) e).getStatus()); } else if (e instanceof AccessDeniedException) { // let Spring handle it by throwing it again throw (AccessDeniedException) e; } else if (e instanceof AuthenticationException) { // let Spring handle it, is a failed login throw (AuthenticationException) e; } else { // Something else, log it and set status to internal server error response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); logException(e);/* w ww . j av a2s. c o m*/ } ModelAndView mav = new ModelAndView(new MappingJackson2JsonView()); mav.addObject("error", e.getMessage()); return mav; }
From source file:controller.MunicipiosRestController.java
/** * * @param request/*w ww .j ava 2s. c om*/ * @param response * @return JSON */ @RequestMapping(method = RequestMethod.GET, produces = "application/json") public String getsJSON(HttpServletRequest request, HttpServletResponse response) { MunicipiosDAO tabla = new MunicipiosDAO(); Gson JSON; List<Municipios> lista; try { lista = tabla.selectAll(); if (lista.isEmpty()) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existen elementos"); JSON = new Gson(); return JSON.toJson(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServer", ex.getMessage()); JSON = new Gson(); return JSON.toJson(e); } Datos<Municipios> datos = new Datos<>(); datos.setDatos(lista); JSON = new Gson(); response.setStatus(HttpServletResponse.SC_OK); return JSON.toJson(datos); }
From source file:controller.IndicadoresRestController.java
/** * * @param request/*from w ww . ja v a 2 s. c om*/ * @param response * @return JSON */ @RequestMapping(method = RequestMethod.GET, produces = "application/json") public String getJSON(HttpServletRequest request, HttpServletResponse response) { IndicadoresDAO tabla = new IndicadoresDAO(); Gson JSON; List<Indicadores> lista; try { lista = tabla.selectAll(); if (lista.isEmpty()) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existen elementos"); JSON = new Gson(); return JSON.toJson(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServer", ex.getMessage()); JSON = new Gson(); return JSON.toJson(e); } Datos<Indicadores> datos = new Datos<>(); datos.setDatos(lista); JSON = new Gson(); response.setStatus(HttpServletResponse.SC_OK); return JSON.toJson(datos); }
From source file:fr.epsi.controllers.rest.ProductController.java
@RequestMapping(value = "/product", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Product[] order(HttpServletResponse resp) { try {//from w w w. ja v a 2s.c o m Products productModel = Products.getInstance(); // On recupere le produit par reference Product[] product = productModel.getAllProduct(); if (product != null) { return product; } else { resp.setStatus(HttpServletResponse.SC_BAD_REQUEST); } return null; } catch (Exception e) { resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return null; } }
From source file:com.pureinfo.srm.project.action.CardIdGenerateAction.java
/** * @see com.pureinfo.ark.interaction.ActionBase#executeAction() *//*from w w w . j a va2 s . c om*/ public ActionForward executeAction() throws PureException { try { getCardId(); Document xDoc = makeResponseXML(); try { response.setCharacterEncoding("utf-8"); response.setContentType("text/xml"); response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1 response.setHeader("Pragma", "no-cache"); //HTTP 1.0 response.setDateHeader("Expires", -1); response.setDateHeader("max-age", 0); XMLWriter writer = new XMLWriter(response.getWriter()); writer.write(xDoc); writer.close(); } catch (IOException ex1) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } catch (RuntimeException e) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } return null; }
From source file:se.acrend.christopher.server.web.control.BillingController.java
@RequestMapping(value = "/billing/getProductList") public void getProductList(final HttpServletResponse response) throws IOException { try {//www . j ava2 s .co m ProductList result = billingService.getProductList(); response.setContentType("application/json"); response.setCharacterEncoding("UTF-8"); Gson gson = ParserFactory.createParser(); gson.toJson(result, response.getWriter()); } catch (Exception e) { log.error("Kunde inte hmta prenumeration.", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:controller.TemasNivel1RestController.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public String getJSON(HttpServletRequest request, HttpServletResponse response) { TemasNivel1DAO tabla = new TemasNivel1DAO(); Gson JSON;/*from ww w . j av a 2s. c o m*/ List<TemasNivel1> lista; try { lista = tabla.selectAll(); if (lista.isEmpty()) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existen elementos"); JSON = new Gson(); return JSON.toJson(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServer", ex.getMessage()); JSON = new Gson(); return JSON.toJson(e); } Datos<TemasNivel1> datos = new Datos<>(); datos.setDatos(lista); JSON = new Gson(); response.setStatus(HttpServletResponse.SC_OK); return JSON.toJson(datos); }