List of usage examples for javax.servlet.http HttpServletResponse setStatus
public void setStatus(int sc);
From source file:edu.cornell.mannlib.vitro.webapp.controller.admin.WaitForBackgroundThreadsController.java
private void sendOK(HttpServletResponse resp) throws IOException { log.debug("All threads are idle"); resp.setStatus(SC_OK); resp.getWriter().println("<html><body>All threads are idle.</body></html>"); }
From source file:de.yaio.services.metaextract.server.controller.MetaExtractController.java
@ExceptionHandler(value = { Exception.class, RuntimeException.class, IOException.class }) public void handleAllException(final HttpServletRequest request, final Exception e, final HttpServletResponse response) { LOGGER.info("Exception while running request:" + createRequestLogMessage(request), e); response.setStatus(SC_INTERNAL_SERVER_ERROR); try {/*from www .j a v a 2 s . c o m*/ response.getWriter().append("exception while extracting metadata for requested resource"); } catch (IOException ex) { LOGGER.warn("exception while exceptionhandling", ex); } }
From source file:org.magnum.mobilecloud.video.AppController.java
@RequestMapping(value = VideoSvcApi.VIDEO_SVC_PATH + "/{id}/likedby", method = RequestMethod.GET) public @ResponseBody List<String> getLikedBy(@PathVariable("id") Long id, HttpServletResponse response) { Video v = videos.findOne(id);//from ww w . ja va2 s. c o m if (null == v) { response.setStatus(404); return null; } List<String> usernameList = new ArrayList<String>(); Set<User> userLikesSet = v.getUserLikesSet(); for (User user : userLikesSet) { usernameList.add(user.getUsername()); } response.setStatus(200); return usernameList; }
From source file:org.nekorp.workflow.backend.controller.imp.ClienteControllerImp.java
@Override @RequestMapping(value = "/{id}", method = RequestMethod.POST) public void actualizarCliente(@PathVariable Long id, @Valid @RequestBody Cliente datos, HttpServletResponse response) { if (clienteDao.consultar(id) == null) { response.setStatus(HttpStatus.NOT_FOUND.value()); } else {/*from w ww . jav a 2 s . c om*/ preprocesaCliente(datos); datos.setId(id); clienteDao.guardar(datos); } }
From source file:br.com.munif.personalsecurity.aplicacao.autorizacao.Autorizador.java
protected void methodNotAllowed(HttpServletRequest request, HttpServletResponse response) throws IOException { System.out.println("---->methodNotAllowed from " + request.getRemoteHost()); response.setStatus(HttpStatus.SC_METHOD_NOT_ALLOWED); response.setContentType("application/json;charset=UTF-8"); mapper.writeValue(response.getOutputStream(), "Mtodo no permitido"); }
From source file:ge.taxistgela.servlet.AdminServlet.java
private void toogleBan(SuperUserManager superUserManager, String sID, String password, HttpServletRequest request, HttpServletResponse response) { if (superUserManager == null) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } else {/* w w w . j ava2 s .co m*/ Admin admin = (Admin) request.getSession().getAttribute(Admin.class.getName()); if (admin != null) { if (sID != null) { Integer id = null; try { id = Integer.parseInt(sID); } catch (Exception e) { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return; } SuperDaoUser superUser = superUserManager.getByID(id); if (superUser != null) { superUser.setPassword(password); ErrorCode errorCode = superUserManager.update(superUser); if (errorCode.errorNotAccrued()) { response.setStatus(HttpServletResponse.SC_ACCEPTED); } else { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); } } } else { response.setStatus(HttpServletResponse.SC_FORBIDDEN); } } }
From source file:gr.cti.android.experimentation.controller.BaseController.java
protected JSONObject ok(final HttpServletResponse servletResponse) throws JSONException { servletResponse.setStatus(200); return ok();/*from w w w .java2s. c om*/ }
From source file:org.magnum.dataup.MainController.java
@RequestMapping(value = VideoSvcApi.VIDEO_DATA_PATH, method = RequestMethod.POST) public @ResponseBody VideoStatus setVideoData(@PathVariable("id") long id, final @RequestParam("data") MultipartFile videoData, HttpServletResponse response) { try {/* w ww .ja v a2s . c o m*/ if (!videos.containsKey(id)) { response.setStatus(404); return new VideoStatus(VideoState.READY); } //saveSomeVideo(videos.get(id), (MultipartFile) videoData.getInputStream()); videoDataMgr = VideoFileManager.get(); videoDataMgr.saveVideoData(videos.get(id), videoData.getInputStream()); } catch (IOException e) { e.printStackTrace(); } return new VideoStatus(VideoState.READY); }
From source file:com.enonic.cms.server.service.servlet.CmsDispatcherServlet.java
@Override protected void doOptions(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setHeader("Allow", StringUtils.join(ALLOWED_HTTP_METHODS, ",")); response.setStatus(HttpServletResponse.SC_OK); }
From source file:csiro.pidsvc.servlet.info.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse * response)/*from w w w . j a v a2 s . com*/ */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED); }