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:com.pymegest.applicationserver.api.PuestoController.java
@RequestMapping(value = { "/Puesto" }, method = RequestMethod.POST) public void insert(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonInput) { try {//from w ww . j a v a 2 s.c om ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); Puesto puesto = (Puesto) objectMapper.readValue(jsonInput, Puesto.class); if (puesto != null) { puestoDAO.insert(puesto); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json; chaset=UTF-8"); String jsonOutput = objectMapper.writeValueAsString(puesto); response.getWriter().println(jsonOutput); } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); response.setContentType("application/json; chaset=UTF-8"); BussinesMessage mensaje = new BussinesMessage(); mensaje.setMensaje("Imposible insertar un puesto."); String json = objectMapper.writeValueAsString(mensaje); response.getWriter().println(json); } } catch (Exception ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.setContentType("text/plain; charset=UTF-8;"); try { ex.printStackTrace(response.getWriter()); } catch (IOException ex1) { } } }
From source file:com.carolinarollergirls.scoreboard.jetty.XmlScoreBoardServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { super.doGet(request, response); try {//from w w w .j a v a2 s .c om if ("/get".equals(request.getPathInfo())) get(request, response); else if ("/debug".equals(request.getPathInfo())) setDebug(request, response); else if ("/config".equals(request.getPathInfo())) listenerConfig(request, response); else if (request.getPathInfo().endsWith(".xml")) getAll(request, response); else if (!response.isCommitted()) response.sendError(HttpServletResponse.SC_NOT_FOUND); } catch (JDOMException jE) { ScoreBoardManager.printMessage("XmlScoreBoardServlet ERROR: " + jE.getMessage()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:org.mypackage.spring.controllers.EmailsSpringController.java
@RequestMapping(value = "/contacts/{id}/modify/update_email/{emailId}", method = RequestMethod.GET) public ModelAndView getUpdateEmail(@PathVariable String id, @PathVariable String emailId) { ModelAndView modelAndView = new ModelAndView(); try {/* w w w . jav a 2 s. com*/ Email email = updateEmailController.retrieveEmail(emailId); modelAndView.addObject(id); modelAndView.addObject("emailId", email.getId()); modelAndView.addObject("email", email); modelAndView.addObject("mailCategories", Email.Category.values()); modelAndView.setViewName("/updateEmail.jsp"); } catch (DalException ex) { logger.error("A database error occured while trying to retrieve contact with ID = " + id, ex); modelAndView.addObject("errorCode", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); modelAndView.addObject("errorMessage", "There was a an internal database error."); modelAndView.setViewName("errorPage.jsp"); } catch (MalformedIdentifierException ex) { modelAndView.addObject("errorCode", HttpServletResponse.SC_BAD_REQUEST); modelAndView.addObject("errorMessage", "An error occured because of a malformed id (caused by id = " + id + "). Please use only numeric values."); modelAndView.setViewName("/errorPage.jsp"); } return modelAndView; }
From source file:edu.uci.ics.asterix.api.http.servlet.RESTAPIServlet.java
public void handleRequest(HttpServletRequest request, HttpServletResponse response, String query) throws IOException { SessionConfig sessionConfig = initResponse(request, response); AqlTranslator.ResultDelivery resultDelivery = whichResultDelivery(request); ServletContext context = getServletContext(); IHyracksClientConnection hcc;/*from ww w .ja v a2 s .com*/ IHyracksDataset hds; try { synchronized (context) { hcc = (IHyracksClientConnection) context.getAttribute(HYRACKS_CONNECTION_ATTR); hds = (IHyracksDataset) context.getAttribute(HYRACKS_DATASET_ATTR); if (hds == null) { hds = new HyracksDataset(hcc, ResultReader.FRAME_SIZE, ResultReader.NUM_READERS); context.setAttribute(HYRACKS_DATASET_ATTR, hds); } } AQLParser parser = new AQLParser(query); List<Statement> aqlStatements = parser.parse(); if (!containsForbiddenStatements(aqlStatements)) { MetadataManager.INSTANCE.init(); AqlTranslator aqlTranslator = new AqlTranslator(aqlStatements, sessionConfig); aqlTranslator.compileAndExecute(hcc, hds, resultDelivery); } } catch (ParseException | TokenMgrError | edu.uci.ics.asterix.aqlplus.parser.TokenMgrError pe) { GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, pe.getMessage(), pe); String errorMessage = ResultUtils.buildParseExceptionMessage(pe, query); JSONObject errorResp = ResultUtils.getErrorResponse(2, errorMessage, "", ""); sessionConfig.out().write(errorResp.toString()); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (Exception e) { GlobalConfig.ASTERIX_LOGGER.log(Level.SEVERE, e.getMessage(), e); ResultUtils.apiErrorHandler(sessionConfig.out(), e); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:com.pymegest.applicationserver.api.FamiliaController.java
@RequestMapping(value = { "/Familia" }, method = RequestMethod.POST) public void insert(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonInput) { try {/*from w ww . ja v a2s . c om*/ ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); Familia familia = (Familia) objectMapper.readValue(jsonInput, Familia.class); if (familia != null) { familiaDAO.insert(familia); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json; chaset=UTF-8"); String jsonOutput = objectMapper.writeValueAsString(familia); response.getWriter().println(jsonOutput); } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); response.setContentType("application/json; chaset=UTF-8"); BussinesMessage mensaje = new BussinesMessage(); mensaje.setMensaje("Imposible insertar un puesto de trabajo."); String json = objectMapper.writeValueAsString(mensaje); response.getWriter().println(json); } } catch (Exception ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.setContentType("text/plain; charset=UTF-8;"); try { ex.printStackTrace(response.getWriter()); } catch (IOException ex1) { } } }
From source file:com.pymegest.applicationserver.api.UsuarioController.java
@RequestMapping(value = { "/Usuario" }, method = RequestMethod.POST) public void insert(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonInput) { try {//from ww w. jav a 2 s . c om ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); Usuario usuario = (Usuario) objectMapper.readValue(jsonInput, Usuario.class); if (usuario != null) { usuarioDAO.insert(usuario); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json; chaset=UTF-8"); String jsonOutput = objectMapper.writeValueAsString(usuario); response.getWriter().println(jsonOutput); } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); response.setContentType("application/json; chaset=UTF-8"); BussinesMessage mensaje = new BussinesMessage(); mensaje.setMensaje("Imposible insertar un usuario."); String json = objectMapper.writeValueAsString(mensaje); response.getWriter().println(json); } } catch (Exception ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.setContentType("text/plain; charset=UTF-8;"); try { ex.printStackTrace(response.getWriter()); } catch (IOException ex1) { } } }
From source file:com.pymegest.applicationserver.api.ProductoController.java
@RequestMapping(value = { "/Producto" }, method = RequestMethod.POST) public void insert(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonInput) { try {/* w ww . ja v a 2 s . c o m*/ ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); Producto producto = (Producto) objectMapper.readValue(jsonInput, Producto.class); if (producto != null) { productoDAO.insert(producto); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json; chaset=UTF-8"); String jsonOutput = objectMapper.writeValueAsString(producto); response.getWriter().println(jsonOutput); } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); response.setContentType("application/json; chaset=UTF-8"); BussinesMessage mensaje = new BussinesMessage(); mensaje.setMensaje("Imposible insertar un producto."); String json = objectMapper.writeValueAsString(mensaje); response.getWriter().println(json); } } catch (Exception ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.setContentType("text/plain; charset=UTF-8;"); try { ex.printStackTrace(response.getWriter()); } catch (IOException ex1) { } } }
From source file:com.pymegest.applicationserver.api.EmpleadoController.java
@RequestMapping(value = { "/Empleado" }, method = RequestMethod.POST) public void insert(HttpServletRequest request, HttpServletResponse response, @RequestBody String jsonInput) { try {/* w w w . j a va 2 s . c om*/ ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); Empleado empleado = (Empleado) objectMapper.readValue(jsonInput, Empleado.class); if (empleado != null) { empleadoDAO.insert(empleado); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json; chaset=UTF-8"); String jsonOutput = objectMapper.writeValueAsString(empleado); response.getWriter().println(jsonOutput); } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); response.setContentType("application/json; chaset=UTF-8"); BussinesMessage mensaje = new BussinesMessage(); mensaje.setMensaje("Imposible insertar un empleado."); String json = objectMapper.writeValueAsString(mensaje); response.getWriter().println(json); } } catch (Exception ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.setContentType("text/plain; charset=UTF-8;"); try { ex.printStackTrace(response.getWriter()); } catch (IOException ex1) { } } }
From source file:org.mypackage.spring.controllers.ContactsSpringController.java
@RequestMapping(value = "/contacts", method = RequestMethod.POST) public ModelAndView postCreateNewContact(@RequestParam("fullname") String fullName, @RequestParam("nickname") String nickname, @RequestParam("notes") String notes) { ModelAndView modelAndView = new ModelAndView(); try {//from ww w. j a v a2 s . c o m int c = newContactController.addNewContact(fullName, nickname, notes); modelAndView.setViewName("redirect:/contacts/" + c); } catch (DalException ex) { logger.error("A database error occured while trying to create a contact with the following parameters:" + "\nFull Name: " + fullName + "\nNick name: " + nickname + "\nNotes: " + notes, ex); modelAndView.addObject("errorCode", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); modelAndView.addObject("errorMessage", "There was a an internal database error."); modelAndView.setViewName("/errorPage.jsp"); } return modelAndView; }
From source file:edu.indiana.d2i.htrc.oauth2.userinfo.OAuth2UserInfoEndpoint.java
private Response handleOAuthClientException() throws OAuthSystemException { OAuthResponse response = OAuthASResponse.errorResponse(HttpServletResponse.SC_INTERNAL_SERVER_ERROR) .setError(OAuth2ErrorCodes.SERVER_ERROR).setErrorDescription("Error while invoking OAuth2 service.") .buildJSONMessage();//w w w .j av a 2s. c om return Response.status(response.getResponseStatus()) .header(OAuthConstants.HTTP_RESP_HEADER_AUTHENTICATE, OAuthUIUtil.getRealmInfo()) .entity(response.getBody()).build(); }