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.nabla.dc.server.ImageService.java
@Override public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException { final String imageId = request.getParameter("id"); if (imageId == null || imageId.isEmpty()) { if (log.isTraceEnabled()) log.trace("missing image ID"); response.sendError(HttpServletResponse.SC_NOT_FOUND); } else {//from w w w .j a va 2s .c om try { if (exportImage(imageId, response)) { // response.setStatus(HttpServletResponse.SC_OK); } else response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (final SQLException e) { if (log.isErrorEnabled()) log.error("SQL error " + e.getErrorCode() + "-" + e.getSQLState(), e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (final Throwable e) { if (log.isErrorEnabled()) log.error("unexpected error", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } }
From source file:de.mpg.imeji.presentation.servlet.ExportServlet.java
/** * {@inheritDoc}/*from w w w.jav a2 s. c o m*/ */ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { SessionBean session = getSessionBean(req, resp); String instanceName = session.getInstanceName(); User user = session.getUser(); try { ExportManager exportManager = new ExportManager(resp.getOutputStream(), user, req.getParameterMap()); String exportName = instanceName + "_"; exportName += new Date().toString().replace(" ", "_").replace(":", "-"); if (exportManager.getContentType().equalsIgnoreCase("application/xml")) { exportName += ".xml"; } if (exportManager.getContentType().equalsIgnoreCase("application/zip")) { exportName += ".zip"; } resp.setHeader("Connection", "close"); resp.setHeader("Content-Type", exportManager.getContentType()); resp.setHeader("Content-disposition", "filename=" + exportName); resp.setStatus(HttpServletResponse.SC_OK); SearchResult result = exportManager.search(); exportManager.export(result); resp.getOutputStream().flush(); } catch (HttpResponseException he) { resp.sendError(he.getStatusCode(), he.getMessage()); } catch (Exception e) { resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } }
From source file:ge.taxistgela.servlet.RegistrationServlet.java
public void registerUser(HttpServletRequest request, HttpServletResponse response) throws IOException { if (!verify(request, response)) return;/*from w w w . ja va 2 s. c o m*/ UserManagerAPI userManager = (UserManagerAPI) request.getServletContext() .getAttribute(UserManagerAPI.class.getName()); UserPreference userPreference = new UserPreference(-1, 0.1, false, 1900, Integer.MAX_VALUE, 5, false); ErrorCode code = userManager.insertUserPreference(userPreference); if (code.errorAccrued()) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } User user = new User(-1, request.getParameter("useremail"), request.getParameter("userpassword"), request.getParameter("userfirstName"), request.getParameter("userlastName"), request.getParameter("userphoneNumber"), getGender(request.getParameter("usergender")), filterSocialID(request.getParameter("userfacebookId")), filterSocialID(request.getParameter("usergoogleplusId")), 5.0, userPreference, false, false); registerSuper(userManager, user, request, response); }
From source file:com.yunda.htmlsnap.web.api.HtmlSnapController.java
@RequestMapping(method = RequestMethod.GET) public void snap(@RequestParam("htmlUrl") String htmlUrl, @RequestParam("imgType") String imgType, HttpServletRequest request, HttpServletResponse response) { logger.info("?:" + htmlUrl); //JavaHost.printAllVirtualDns(); response.setContentType("image/" + imgType); response.setHeader("Content-Type", "image/" + imgType); boolean flag = false; ServletOutputStream sos = null;// ww w.ja va 2s.c om if (StringUtils.isNotBlank(htmlUrl)) { BrowserService browserService = null; try { browserService = BrowserFactory.getBrowerService(); sos = response.getOutputStream(); flag = browserService.generatePng(URLDecoder.decode(htmlUrl, "UTF-8"), sos, imgType); } catch (IOException e) { logger.error("??:" + e); } finally { BrowserFactory.recycleService(browserService); } } logger.info("?" + flag); if (!flag) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } if (null != sos) { try { sos.flush(); sos.close(); } catch (IOException e1) { logger.error("?", e1); } } }
From source file:com.tapas.evidence.fe.controller.CaptchaController.java
@RequestMapping("/captcha.jpg") public void showForm(HttpServletRequest request, HttpServletResponse response) throws Exception { byte[] captchaChallengeAsJpeg = null; // the output stream to render the captcha image as jpeg into ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream(); try {/*from w w w.ja va2 s . com*/ // get the session id that will identify the generated captcha. // the same id must be used to validate the response, the session id is a good candidate! String captchaId = request.getSession().getId(); BufferedImage challenge = captchaService.getImageChallengeForID(captchaId, request.getLocale()); ImageIO.write(challenge, CAPTCHA_IMAGE_FORMAT, jpegOutputStream); } catch (IllegalArgumentException e) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } catch (CaptchaServiceException e) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } captchaChallengeAsJpeg = jpegOutputStream.toByteArray(); // flush it in the response response.setHeader("Cache-Control", "no-store"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0); response.setContentType("image/" + CAPTCHA_IMAGE_FORMAT); ServletOutputStream responseOutputStream = response.getOutputStream(); responseOutputStream.write(captchaChallengeAsJpeg); responseOutputStream.flush(); responseOutputStream.close(); }
From source file:com.adito.setup.actions.MessageQueueInformationAction.java
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try {//from w ww . j a va 2s. c o m long messageId = Long.parseLong(request.getParameter("messageId")); MessageWrapper message = CoreServlet.getServlet().getNotifier().getMessage(messageId); request.setAttribute(Constants.REQ_ATTR_INFO_RESOURCE, message); return messageQueueInformation(mapping, form, request, response); } catch (Exception e) { log.error("Failed to get message information. ", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } return null; }
From source file:com.adito.keystore.actions.KeyStoreInformationAction.java
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try {/* w w w . j a v a2s . c om*/ String alias = request.getParameter("alias"); String type = request.getParameter("type"); ((KeyStoreInformationForm) form).initialise(alias, type); return mapping.findForward("display"); } catch (Exception e) { log.error("Failed to get keystore information. ", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); return null; } }
From source file:org.apache.cxf.fediz.service.idp.MetadataServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/xml; charset=utf-8"); PrintWriter out = response.getWriter(); try {//from w w w . ja v a 2s. c om ConfigService cs = (ConfigService) getApplicationContext().getBean("config"); Idp idpConfig = cs.getIDP(realm); LOG.debug(idpConfig.toString()); MetadataWriter mw = new MetadataWriter(); Document metadata = mw.getMetaData(idpConfig); out.write(DOM2Writer.nodeToString(metadata)); } catch (Exception ex) { LOG.error("Failed to get metadata document: ", ex); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:fr.epsi.controllers.rest.LoginController.java
/** * Methode qui deconnecte un utilisateur * @param guid le guid de l'utilisateur connecte */// w w w . j av a2 s .c o m @RequestMapping(value = "/disconnect", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody void disconnect(@RequestParam("token") String token, HttpServletResponse resp) { try { // On recupre l'instance et on la supprime Users userModel = Users.getInstance(); User user = userModel.findByGUID(token); if (user != null) { user.clearGUID(); resp.setStatus(HttpServletResponse.SC_OK); } else { resp.setStatus(HttpServletResponse.SC_FORBIDDEN); } } catch (Exception e) { resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:com.adito.security.actions.IpRestrictionInformationAction.java
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try {// w ww . jav a 2 s .c o m String allowed = request.getParameter("allowed"); String ip = request.getParameter("ip"); ((IpRestrictionInformationForm) form).initialise(allowed, ip); ; return mapping.findForward("display"); } catch (Exception e) { log.error("Failed to get extension information. ", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); return null; } }