List of usage examples for javax.servlet.http HttpServletResponse setStatus
public void setStatus(int sc);
From source file:byps.http.HActiveMessage.java
public synchronized void cancelMessage() { if (log.isDebugEnabled()) log.debug("cancelMessage(" + messageId); canceled = true;//from ww w .ja v a 2 s . c o m // Threads might wait in getIncomingStream() this.notifyAll(); Thread thread = workerThread; if (log.isDebugEnabled()) log.debug("worker is still running: " + (thread != null)); if (thread != null) { if (log.isDebugEnabled()) log.debug("interrupt thread=" + thread); thread.interrupt(); // The worker thread will call RequestContext.complete // when it is finished. } else if (rctxtMessage != null) { if (log.isDebugEnabled()) log.debug("assume long-poll, complete response with HTTP 410"); // Assume Longpoll request because a worker thread would have called // getAndRemoveRequestContext // before it has called removeWorker. // This block is executed, if the session is invalidated. // The response code is SC_GONE in order to stop HServerR on the // client side from // sending a new long-poll. HttpServletResponse resp = (HttpServletResponse) rctxtMessage.getResponse(); resp.setStatus(HttpServletResponse.SC_GONE); rctxtMessage.complete(); rctxtMessage = null; } incomingStreams.clear(); checkFinished(); if (log.isDebugEnabled()) log.debug(")cancelMessage"); }
From source file:edu.unc.lib.dl.cdr.sword.server.servlets.ContainerServlet.java
@RequestMapping(value = { "/{pid}", "/{pid}/*" }, method = RequestMethod.DELETE) public void deleteContainer(HttpServletRequest req, HttpServletResponse resp) { try {/*from w w w . j a va2 s .c om*/ this.api.delete(req, resp); } catch (Exception e) { log.error("Failed to delete container " + req.getQueryString(), e); resp.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR); } }
From source file:de.hybris.platform.assistedservicestorefront.controllers.CustomerListController.java
/** * Method responsible for getting available customer list for agent and return a popup with the data * * @param model/*from w ww .ja va2s .c o m*/ * model to hold the populated data * @return the popup with list of customers list populated */ @RequestMapping(value = "/availableCustomerLists", method = RequestMethod.GET) public String getCustomersListPopup(final Model model, final HttpServletResponse response) { if (!assistedServiceFacade.isAssistedServiceAgentLoggedIn()) { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); assistedServiceFacade.getAsmSession().setFlashErrorMessage("asm.emulate.error.agent_missed"); return null; } final List<UserGroupData> customerLists = customerListFacade .getCustomerListsForEmployee(assistedServiceFacade.getAsmSession().getAgent().getUid()); // Handle paged search results if (!CollectionUtils.isEmpty(customerLists)) { model.addAttribute(AVAILABLE_CUSTOMER_LIST, customerLists); model.addAttribute(DEFAULT_CUSTOMER_LIST, customerLists.get(0).getUid()); } return AssistedservicestorefrontControllerConstants.Views.Fragments.CustomerListComponent.ASMCustomerListPopup; }
From source file:fi.hoski.web.forms.EventServlet.java
private void sendError(HttpServletResponse response, int statusCode, String htmlMessage) throws IOException { response.setStatus(statusCode); response.setContentType("text/html"); response.setCharacterEncoding("utf-8"); response.getWriter().write(htmlMessage); }
From source file:SiteSelector.java
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); int siteIndex = Math.abs(random.nextInt()) % sites.size(); String site = sites.elementAt(siteIndex); res.setStatus(res.SC_MOVED_TEMPORARILY); res.setHeader("Location", site); }
From source file:com.surevine.alfresco.audit.integration.ResponseModifiableMockFilterChain.java
@Override public void doFilter(final ServletRequest request, final ServletResponse response) { super.doFilter(request, response); try {/*from w w w.j av a2 s. c o m*/ HttpServletResponse httpServletResponse = (HttpServletResponse) response; httpServletResponse.getOutputStream().write(content.getBytes()); httpServletResponse.setContentLength(content.length()); httpServletResponse.setStatus(this.status); httpServletResponse.flushBuffer(); } catch (IOException e) { e.printStackTrace(); } }
From source file:net.prasenjit.auth.config.CustomAjaxAwareHandler.java
/** {@inheritDoc} */ @Override//from w w w. ja v a 2 s. c o m public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { if (checkIfAjaxRequest(request)) { response.setStatus(HttpStatus.UNAUTHORIZED.value()); } else { delegatedFailureHandler.onAuthenticationFailure(request, response, exception); } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.admin.WaitForBackgroundThreadsController.java
private void sendRedirect(HttpServletResponse resp, String redirect) { log.debug("All threads are idle. Redirecting to '" + redirect + "'"); resp.setStatus(SC_TEMPORARY_REDIRECT); resp.setHeader(HEADER_LOCATION, redirect); }
From source file:org.broadleafcommerce.admin.util.controllers.MakeDirectoryController.java
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { DirectoryFileBean bean = (DirectoryFileBean) command; checkDirectory(bean.getAbsolutePath() + File.separator + bean.getName()); response.setStatus(HttpServletResponse.SC_OK); return super.onSubmit(request, response, command, errors); }
From source file:edu.cornell.mannlib.vitro.webapp.controller.json.JsonArrayProducer.java
public final void process(HttpServletResponse resp) throws IOException { JSONArray jsonArray = null;/*w w w.j a v a 2 s . c o m*/ try { jsonArray = process(); } catch (Exception e) { log.error("Failed to create JSON response" + e); resp.setStatus(500 /* HttpURLConnection.HTTP_SERVER_ERROR */); } if (jsonArray == null) { jsonArray = new JSONArray(); } log.debug("Response to JSON request: " + jsonArray.toString()); resp.setCharacterEncoding("UTF-8"); resp.setContentType("application/json;charset=UTF-8"); Writer writer = resp.getWriter(); writer.write(jsonArray.toString()); }