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.UsuarioController.java
@RequestMapping(value = { "/Usuario" }, method = RequestMethod.GET) public void findAll(HttpServletRequest request, HttpServletResponse response) { try {//from w ww . jav a 2 s.co m List<Usuario> usuarios = usuarioDAO.findAll(); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json; chaset=UTF-8"); ObjectMapper objectMapper = new ObjectMapper(); String json = objectMapper.writeValueAsString(usuarios); 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.GET) public void findAll(HttpServletRequest request, HttpServletResponse response) { try {//from w ww. ja v a2s . c om List<Producto> productos = productoDAO.findAll(); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json; chaset=UTF-8"); ObjectMapper objectMapper = new ObjectMapper(); String json = objectMapper.writeValueAsString(productos); 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.GET) public void findAll(HttpServletRequest request, HttpServletResponse response) { try {/*from w w w . j a va 2s . c om*/ List<Empleado> empleado = empleadoDAO.findAll(); response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/json; chaset=UTF-8"); ObjectMapper objectMapper = new ObjectMapper(); String json = objectMapper.writeValueAsString(empleado); 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.lareferencia.xoai.controller.LROAIDataProvider.java
@RequestMapping("/{context}") public String contextAction(Model model, HttpServletRequest request, HttpServletResponse response, @PathVariable("context") String xoaiContext) throws IOException, ServletException { Context context = null;//from www . j a v a 2 s . co m try { request.setCharacterEncoding("UTF-8"); context = contextService.getContext(); XOAIManager manager = xoaiManagerResolver.getManager(); RepositoryConfiguration identify = identifyResolver.getIdentify(); OAIDataProvider dataProvider = new OAIDataProvider(manager, xoaiContext, identify, setRepositoryResolver.getSetRepository(), itemRepositoryResolver.getItemRepository(), resumptionTokenFormat); OutputStream out = response.getOutputStream(); OAIRequestParameters parameters = new OAIRequestParameters(buildParametersMap(request)); response.setContentType("application/xml"); response.setCharacterEncoding("UTF-8"); String identification = xoaiContext + parameters.requestID(); if (cacheService.isActive()) { if (!cacheService.hasCache(identification)) cacheService.store(identification, dataProvider.handle(parameters)); cacheService.handle(identification, out); } else dataProvider.handle(parameters, out); out.flush(); out.close(); closeContext(context); } catch (InvalidContextException e) { log.debug(e.getMessage(), e); return indexAction(response, model); } catch (ContextServiceException e) { log.error(e.getMessage(), e); closeContext(context); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unexpected error while writing the output. For more information visit the log files."); } catch (XOAIManagerResolverException e) { throw new ServletException( "OAI 2.0 wasn't correctly initialized, please check the log for previous errors", e); } catch (OAIException e) { log.error(e.getMessage(), e); closeContext(context); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unexpected error. For more information visit the log files."); } catch (WritingXmlException e) { log.error(e.getMessage(), e); closeContext(context); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unexpected error while writing the output. For more information visit the log files."); } catch (XMLStreamException e) { log.error(e.getMessage(), e); closeContext(context); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unexpected error while writing the output. For more information visit the log files."); } finally { closeContext(context); } return null; // response without content }
From source file:org.mypackage.spring.controllers.EmailsSpringController.java
@RequestMapping(value = "/contacts/{id}/modify/delete_email/{emailId}", method = RequestMethod.GET) public ModelAndView getDeleteEmail(@PathVariable String id, @PathVariable String emailId) { ModelAndView modelAndView = new ModelAndView(); modelAndView.addObject(id);//from w w w .j a v a 2 s. c o m try { this.deleteEmailController.deleteEmail(emailId); modelAndView.setViewName("/contacts/" + id + "/modify"); } catch (DalException ex) { logger.error("A database error occured while trying to delete 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. Please use only numeric values."); modelAndView.setViewName("/errorPage.jsp"); } return modelAndView; }
From source file:com.hp.autonomy.frontend.find.hod.view.HodViewController.java
@ExceptionHandler @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) public ModelAndView handleGeneralException(final Exception e, final HttpServletRequest request, final ServletResponse response) { response.reset();// w w w. ja va 2 s .c o m return controllerUtils.buildErrorModelAndView(new ErrorModelAndViewInfo.Builder().setRequest(request) .setMainMessageCode(HOD_ERROR_MESSAGE_CODE_INTERNAL_MAIN) .setSubMessageCode(HOD_ERROR_MESSAGE_CODE_INTERNAL_SUB) .setStatusCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).setContactSupport(true).setException(e) .build()); }
From source file:eu.trentorise.smartcampus.permissionprovider.controller.BasicProfileController.java
@RequestMapping(method = RequestMethod.GET, value = "/accountprofile/me") public @ResponseBody AccountProfile findAccountProfile(HttpServletResponse response) throws IOException { try {/*from w w w.ja v a2 s. c om*/ Long user = getUserId(); if (user == null) { response.setStatus(HttpServletResponse.SC_FORBIDDEN); return null; } return profileManager.getAccountProfileById(user.toString()); } catch (Exception e) { e.printStackTrace(); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return null; } }
From source file:com.att.nsa.dmaap.util.ContentLengthInterceptor.java
/** * Intercepter method to intercept requests before processing *//*w ww. j a v a 2 s. c o m*/ @Override public boolean allowOrReject(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, Map map) throws Exception { log.info("inside Interceptor allowOrReject content length checking before pub/sub"); JSONObject jsonObj = null; int requestLength = 0; setDefLength(System.getProperty("maxcontentlength")); try { // retrieving content length from message header if (null != httpservletrequest.getHeader("Content-Length")) { requestLength = Integer.parseInt(httpservletrequest.getHeader("Content-Length")); } // retrieving encoding from message header String transferEncoding = httpservletrequest.getHeader("Transfer-Encoding"); // checking for no encoding, chunked and requestLength greater then // default length if (null != transferEncoding && !(transferEncoding.contains("chunked")) && (requestLength > Integer.parseInt(getDefLength()))) { jsonObj = new JSONObject().append("defaultlength", getDefLength()).append("requestlength", requestLength); log.error("message length is greater than default"); throw new CambriaApiException(jsonObj); } else if (null == transferEncoding && (requestLength > Integer.parseInt(getDefLength()))) { jsonObj = new JSONObject().append("defaultlength", getDefLength()).append("requestlength", requestLength); log.error("Request message is not chunked or request length is greater than default length"); throw new CambriaApiException(jsonObj); } else { //chain.doFilter(req, res); return true; } } catch (CambriaApiException | NumberFormatException | JSONException e) { log.info("Exception obj--" + e); log.error("message size is greater then default" + e.getMessage()); ErrorResponse errRes = new ErrorResponse(HttpStatus.SC_REQUEST_TOO_LONG, DMaaPResponseCode.MSG_SIZE_EXCEEDS_MSG_LIMIT.getResponseCode(), System.getProperty("msg_size_exceeds") + jsonObj.toString()); log.info(errRes.toString()); map.put(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "test"); httpservletresponse.setStatus(HttpStatus.SC_REQUEST_TOO_LONG); httpservletresponse.getOutputStream().write(errRes.toString().getBytes()); return false; } }
From source file:com.flexive.war.servlet.TestRunnerServlet.java
/** * {@inheritDoc}//w w w . ja va2 s . c o m */ @Override public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException { final HttpServletRequest request = (HttpServletRequest) servletRequest; final HttpServletResponse response = (HttpServletResponse) servletResponse; String cmd = URLDecoder.decode(request.getRequestURI(), "UTF8"); if (cmd != null && cmd.lastIndexOf('/') > 0) cmd = cmd.substring(cmd.lastIndexOf('/') + 1); if (CMD_AVAILABLE.equals(cmd)) { boolean available = false; try { Class.forName("com.flexive.testRunner.FxTestRunner"); available = true; } catch (Exception e) { LOG.error(e); } response.setStatus(available ? HttpServletResponse.SC_OK : HttpServletResponse.SC_SERVICE_UNAVAILABLE); response.getWriter().write(String.valueOf(available)); } else if (CMD_RUN.equals(cmd)) { String outputPath = request.getParameter(PARAM_OUTPUTPATH); try { Class runner = Class.forName("com.flexive.testRunner.FxTestRunner"); Method check = runner.getMethod("checkTestConditions", String.class, Boolean.class); Boolean status = false; if (!StringUtils.isEmpty(outputPath)) status = (Boolean) check.invoke(null, String.valueOf(outputPath), Boolean.FALSE); if (!status) { response.setStatus(HttpServletResponse.SC_PRECONDITION_FAILED); response.getWriter() .write("Invalid output path, assertations not enabled or test division not definied!"); return; } Method exec = runner.getMethod("runTests", String.class); exec.invoke(null, outputPath); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().write("Tests started."); } catch (Exception e) { LOG.error(e); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.getWriter().write("Error: " + e.getMessage()); } } else if (CMD_RUNNING.equals(cmd)) { try { Class runner = Class.forName("com.flexive.testRunner.FxTestRunner"); Method check = runner.getMethod("isTestInProgress"); Boolean status = (Boolean) check.invoke(null); response.setStatus(HttpServletResponse.SC_OK); response.getWriter().write(String.valueOf(status)); } catch (Exception e) { LOG.error(e); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.getWriter().write("Error: " + e.getMessage()); } } else { response.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); response.getWriter().write("Unknown command: " + cmd); } }
From source file:de.mpg.mpdl.service.rest.screenshot.service.HtmlScreenshotServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try {/*from w ww. j a v a 2 s. c om*/ String url = req.getParameter("url"); if (url != null) { browserWidth = (readBrowserParam(req, "browserWidth") != "") ? Integer.parseInt(req.getParameter("browserWidth")) : 1920; browserHeight = (readBrowserParam(req, "browserHeight") != "") ? Integer.parseInt(req.getParameter("browserHeight")) : 1080; useFireFox = (readBrowserParam(req, "useFireFox") != "") ? Boolean.parseBoolean(req.getParameter("useFireFox")) : false; file = screenshotService.takeScreenshot(url, browserWidth, browserHeight, useFireFox); if (transformScreenshot(req)) { imageTransformer.transform(file, resp.getOutputStream(), readParam(req, "format"), readParam(req, "size"), readParam(req, "crop"), readParam(req, "priority"), readParam(req, "params1"), readParam(req, "params2")); } else IOUtils.copy(new FileInputStream(file), resp.getOutputStream()); } } catch (Exception e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); e.printStackTrace(); } }