List of usage examples for javax.servlet.http HttpServletResponse SC_OK
int SC_OK
To view the source code for javax.servlet.http HttpServletResponse SC_OK.
Click Source Link
From source file:org.jboss.as.testsuite.clustering.web.SimpleWebTestCase.java
@Test public void test() throws ClientProtocolException, IOException { DefaultHttpClient client = new DefaultHttpClient(); try {/*from w w w. j a va 2s. c o m*/ HttpResponse response = client.execute(new HttpGet("http://localhost:8080/distributable/simple")); Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals(Integer.parseInt(response.getFirstHeader("value").getValue()), 1); Assert.assertFalse(Boolean.valueOf(response.getFirstHeader("serialized").getValue())); response.getEntity().getContent().close(); response = client.execute(new HttpGet("http://localhost:8080/distributable/simple")); Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals(Integer.parseInt(response.getFirstHeader("value").getValue()), 2); // This won't be true unless we have somewhere to which to replicate Assert.assertFalse(Boolean.valueOf(response.getFirstHeader("serialized").getValue())); response.getEntity().getContent().close(); } finally { client.getConnectionManager().shutdown(); } }
From source file:com.carolinarollergirls.scoreboard.jetty.XmlScoreBoardServlet.java
protected void get(HttpServletRequest request, HttpServletResponse response) throws IOException, JDOMException { XmlListener listener = getXmlListenerForRequest(request); if (null == listener) { registrationKeyNotFound(request, response); return;//from www.j a v a2s. c o m } Document d = listener.getDocument(LONGPOLL_TIMEOUT); if (null == d) { if (debugGet) ScoreBoardManager.printMessage("GET to " + listener.getKey() + " no change"); response.sendError(HttpServletResponse.SC_NOT_MODIFIED); } else { if (debugGet) ScoreBoardManager .printMessage("GET to " + listener.getKey() + "\n" + prettyXmlOutputter.outputString(d)); response.setContentType("text/xml"); rawXmlOutputter.output(d, response.getOutputStream()); response.setStatus(HttpServletResponse.SC_OK); } }
From source file:controller.MunicipiosRestController.java
/** * * @param request/* ww w .j av a2 s . c o m*/ * @param response * @return JSON */ @RequestMapping(method = RequestMethod.GET, produces = "application/json") public String getsJSON(HttpServletRequest request, HttpServletResponse response) { MunicipiosDAO tabla = new MunicipiosDAO(); Gson JSON; List<Municipios> lista; try { lista = tabla.selectAll(); if (lista.isEmpty()) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existen elementos"); JSON = new Gson(); return JSON.toJson(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServer", ex.getMessage()); JSON = new Gson(); return JSON.toJson(e); } Datos<Municipios> datos = new Datos<>(); datos.setDatos(lista); JSON = new Gson(); response.setStatus(HttpServletResponse.SC_OK); return JSON.toJson(datos); }
From source file:controller.IndicadoresRestController.java
/** * * @param request/*from w ww. j av a 2s. c o m*/ * @param response * @return JSON */ @RequestMapping(method = RequestMethod.GET, produces = "application/json") public String getJSON(HttpServletRequest request, HttpServletResponse response) { IndicadoresDAO tabla = new IndicadoresDAO(); Gson JSON; List<Indicadores> lista; try { lista = tabla.selectAll(); if (lista.isEmpty()) { response.setStatus(HttpServletResponse.SC_NOT_FOUND); Error e = new Error(); e.setTypeAndDescription("Warning", "No existen elementos"); JSON = new Gson(); return JSON.toJson(e); } } catch (HibernateException ex) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); Error e = new Error(); e.setTypeAndDescription("errorServer", ex.getMessage()); JSON = new Gson(); return JSON.toJson(e); } Datos<Indicadores> datos = new Datos<>(); datos.setDatos(lista); JSON = new Gson(); response.setStatus(HttpServletResponse.SC_OK); return JSON.toJson(datos); }
From source file:de.hackerspacebremen.commands.WebCommand.java
protected void handleSuccess(final BasicResultObject result) { resp.setStatus(HttpServletResponse.SC_OK); this.result.addSuccess(result); }
From source file:net.proest.librepilot.web.handler.ObjectHandler.java
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setCharacterEncoding("utf-8"); response.setStatus(HttpServletResponse.SC_OK); if (request.getMethod().equals("POST")) { handlePost(target, baseRequest, request, response); } else if (request.getMethod().equals("GET")) { handleGet(target, baseRequest, request, response); }/* w w w. ja va 2s . co m*/ baseRequest.setHandled(true); }
From source file:com.jaspersoft.jasperserver.rest.services.RESTAttribute.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServiceException { restUtils.setStatusAndBody(HttpServletResponse.SC_OK, resp, generateProfileAttributeReport( attributesRemoteService.getAttributesOfUser(restUtils.extractResourceName(req.getPathInfo())))); }
From source file:com.berrysys.ussdgw.HttpUtils.java
/** * Queue full logic./* w w w . j a v a2s . co m*/ * * @param resp the resp * @throws IOException Signals that an I/O exception has occurred. */ private static void queueFullLogic(HttpServletResponse resp) throws IOException { // TODO Auto-generated method stub String response = "Message Queue full"; resp.setContentType("text/html"); resp.setStatus(HttpServletResponse.SC_OK); resp.getWriter().println(response); }
From source file:jp.mathes.databaseWiki.dav.DavServlet.java
@Override public void service(final javax.servlet.ServletRequest servletRequest, final javax.servlet.ServletResponse servletResponse) throws ServletException, IOException { HttpServletRequest req = (HttpServletRequest) servletRequest; HttpServletResponse resp = (HttpServletResponse) servletResponse; if (req.getHeader("Authorization") != null) { resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType("application/xhtml+xml"); try {/*ww w . j a v a 2s.c om*/ Request request = new ServletRequest(req); Response response = new ServletResponse(resp); this.httpManager.process(request, response); } finally { servletResponse.getOutputStream().flush(); servletResponse.flushBuffer(); } } else { resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED); resp.setHeader("WWW-Authenticate", "Basic realm=\"databaseWiki\""); } }
From source file:tachyon.metrics.sink.MetricsServlet.java
private HttpServlet createServlet() { return new HttpServlet() { @Override/* ww w . jav a2 s . co m*/ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(String.format("text/json;charset=utf-8")); response.setStatus(HttpServletResponse.SC_OK); response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); String result = mObjectMapper.writeValueAsString(mMetricsRegistry); response.getWriter().println(result); } }; }