Example usage for javax.servlet.http HttpServletResponse SC_OK

List of usage examples for javax.servlet.http HttpServletResponse SC_OK

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletResponse SC_OK.

Prototype

int SC_OK

To view the source code for javax.servlet.http HttpServletResponse SC_OK.

Click Source Link

Document

Status code (200) indicating the request succeeded normally.

Usage

From source file:com.nesscomputing.httpclient.testsupport.GenericWritingContentHandler.java

@Override
public void handle(final String target, final Request request, final HttpServletRequest httpRequest,
        final HttpServletResponse httpResponse) throws IOException, ServletException {
    method = request.getMethod();/*  w  w w.j a v  a  2s . co  m*/

    InputStream inputStream = request.getInputStream();

    postData = IOUtils.toString(inputStream);

    httpResponse.setContentType(contentType);
    httpResponse.setStatus(HttpServletResponse.SC_OK);

    request.setHandled(true);

    final PrintWriter writer = httpResponse.getWriter();
    writer.print(content);
    writer.flush();
}

From source file:org.vbossica.springbox.metrics.ThreadDumpController.java

@RequestMapping(value = "/metrics/threaddump", method = RequestMethod.GET)
protected void doGet(HttpServletResponse resp) throws ServletException, IOException {
    resp.setContentType("text/plain");
    resp.setHeader("Cache-Control", "must-revalidate,no-cache,no-store");
    resp.setStatus(HttpServletResponse.SC_OK);
    OutputStream output = resp.getOutputStream();
    try {// w w w. ja  va2 s .c o m
        threadDump.dump(output);
    } finally {
        output.close();
    }
}

From source file:com.google.android.gcm.demo.server.AlertsServlet.java

/**
 * Displays the existing messages and offer the option to send a new one.
 *///  w  w w .  java  2 s .c om
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("application/json");

    String limit = req.getParameter("limit");
    String offset = req.getParameter("offset");

    JSONArray alerts = Datastore.getAllAlerts(Integer.parseInt(offset), Integer.parseInt(limit));
    PrintWriter out = resp.getWriter();
    out.print(alerts);
    resp.setStatus(HttpServletResponse.SC_OK);
}

From source file:gsn.http.AddressingReqHandler.java

public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
    response.setStatus(HttpServletResponse.SC_OK);
    String vsName = request.getParameter("name");
    VSensorConfig sensorConfig = Mappings.getVSensorConfig(vsName);
    logger.info(new StringBuilder().append("Structure request for *").append(vsName).append("* received.")
            .toString());/*from www.ja va  2  s .  c om*/
    StringBuilder sb = new StringBuilder("<virtual-sensor name=\"").append(vsName).append("\" last-modified=\"")
            .append(new File(sensorConfig.getFileName()).lastModified()).append("\">\n");
    for (KeyValue df : sensorConfig.getAddressing())
        sb.append("<predicate key=\"").append(StringEscapeUtils.escapeXml(df.getKey().toString())).append("\">")
                .append(StringEscapeUtils.escapeXml(df.getValue().toString())).append("</predicate>\n");
    sb.append("</virtual-sensor>");
    response.setHeader("Cache-Control", "no-store");
    response.setDateHeader("Expires", 0);
    response.setHeader("Pragma", "no-cache");
    response.getWriter().write(sb.toString());
}

From source file:com.greenline.guahao.web.module.common.exception.PortalExceptionResolver.java

@Override
public ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
        Exception ex) {/*w ww  . jav a  2  s. c  o m*/
    logger.error("url=" + (request.getServerName() + CommonUtils.getBeforeRepath(request)));
    // ?
    ModelAndView mv = super.doResolveException(request, response, handler, ex);
    mv.setViewName(domainFilter.getAuthorization(request).getErrorViewName(request, response));
    response.setStatus(HttpServletResponse.SC_OK);
    String servername = (String) request.getAttribute("servername");
    if (StringUtils.isNotBlank(servername)) {
        // ???url 0 1?
        String domain_showurl = (String) request.getAttribute("domain_showurl");
        if (StringUtils.isNotBlank(domain_showurl) && "0".equals(domain_showurl)) {
            String domainservername = request.getScheme() + "://" + servername
                    + CommonUtils.getServerPort(request);
            mv.getModelMap().put("guahaoServer", domainservername);
        }
    }
    return mv;
}

From source file:baggage.hypertoolkit.views.InputStreamResource.java

@Override
public int getHttpStatus() {
    return HttpServletResponse.SC_OK;
}

From source file:gsn.http.OutputStructureHandler.java

public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
    response.setStatus(HttpServletResponse.SC_OK);
    String vsName = request.getParameter("name");
    VSensorConfig sensorConfig = Mappings.getVSensorConfig(vsName);
    logger.info(new StringBuilder().append("Structure request for *").append(vsName).append("* received.")
            .toString());/*w  w  w . j  ava2s  . c  om*/
    StringBuilder sb = new StringBuilder("<virtual-sensor name=\"").append(vsName).append("\">\n");
    sb.append(
            "<field name=\"time\" type=\"string\" description=\"The timestamp associated with the stream element\" unit=\"\"/>\n");
    for (DataField df : sensorConfig.getOutputStructure()) {
        sb.append("<field name=\"").append(df.getName()).append("\" ").append("type=\"").append(df.getType())
                .append("\" ").append("description=\"")
                .append(StringEscapeUtils.escapeXml(df.getDescription()));
        if (df.getUnit() != null && df.getUnit().trim().length() != 0)
            sb.append("\" ").append("unit=\"").append(df.getUnit());
        else
            sb.append("\" ").append("unit=\"").append("");
        sb.append("\" />\n");
    }
    sb.append("</virtual-sensor>");
    response.setHeader("Cache-Control", "no-store");
    response.setDateHeader("Expires", 0);
    response.setHeader("Pragma", "no-cache");
    response.getWriter().write(sb.toString());
}

From source file:com.ge.apm.web.WeChatCoreController.java

/**
 * ?webservice??????//from www  .  ja  v  a2 s. co m
 *
 * @param request
 * @param response
 * @throws Exception
 */
@RequestMapping(value = "core")
public void wechatCore(HttpServletRequest request, HttpServletResponse response) throws Exception {
    response.setContentType("text/html;charset=utf-8");
    response.setStatus(HttpServletResponse.SC_OK);

    String signature = request.getParameter("signature");
    String nonce = request.getParameter("nonce");
    String timestamp = request.getParameter("timestamp");

    if (!this.wxMpService.checkSignature(timestamp, nonce, signature)) {
        // ?????????
        response.getWriter().println("?");
        return;
    }

    String echoStr = request.getParameter("echostr");
    if (StringUtils.isNotBlank(echoStr)) {
        // ??echostr
        String echoStrOut = String.copyValueOf(echoStr.toCharArray());
        response.getWriter().println(echoStrOut);
        return;
    }
    System.out.println("current token is \n" + wxMpService.getAccessToken());
    String apiTicket = wxMpService.getJsapiTicket();
    System.out.println("current apiTicket is \n" + apiTicket);
    String encryptType = StringUtils.isBlank(request.getParameter("encrypt_type")) ? "raw"
            : request.getParameter("encrypt_type");

    if ("raw".equals(encryptType)) {
        // ?
        WxMpXmlMessage inMessage = WxMpXmlMessage.fromXml(request.getInputStream());
        WxMpXmlOutMessage outMessage = this.coreService.route(inMessage);
        response.getWriter().write(outMessage == null ? "" : outMessage.toXml());
        return;
    }

    if ("aes".equals(encryptType)) {
        // aes?
        String msgSignature = request.getParameter("msg_signature");
        WxMpXmlMessage inMessage = WxMpXmlMessage.fromEncryptedXml(request.getInputStream(), this.configStorage,
                timestamp, nonce, msgSignature);
        WxMpXmlOutMessage outMessage = this.coreService.route(inMessage);
        response.getWriter().write(outMessage == null ? "" : outMessage.toEncryptedXml(this.configStorage));
        return;
    }

    response.getWriter().println("??");
    return;
}

From source file:fragment.web.ServiceProviderLogoControllerTest.java

@Test
public void testGetFavicon() {
    serviceProviderLogoController.getFavicon(response);
    Assert.assertTrue(response.getContentType().contains("image/"));
    Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatus());
}

From source file:com.jamespot.glifpix.wrappers.SampleHtmlTestService.java

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    response.setStatus(HttpServletResponse.SC_OK);

    PrintWriter out = response.getWriter();

    String htmlPage = FileUtils.readFileToString(new File(props.getProperty("tagsServer.testPage")));

    out.println(htmlPage);//from  w w w  .  j  ava 2s  . co m
}