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.carolinarollergirls.scoreboard.jetty.XmlScoreBoardServlet.java

protected void getAll(HttpServletRequest request, HttpServletResponse response)
        throws IOException, JDOMException {
    response.setContentType("text/xml");
    prettyXmlOutputter.output(scoreBoardModel.getXmlScoreBoard().getDocument(), response.getOutputStream());
    response.setStatus(HttpServletResponse.SC_OK);
}

From source file:com.telefonica.iot.perseo.RulesManager.java

/**
 * Get a rule by name/*ww w .ja  v a 2s . c o  m*/
 *
 * @param epService Esper provider containing rules
 * @param ruleName Name of the rule
 *
 * @return Result object with a code and a JSON response
 */
public static synchronized Result get(EPServiceProvider epService, String ruleName) {
    try {

        logger.debug("rule asked for: " + ruleName);
        ruleName = ruleName == null ? "" : ruleName;
        EPAdministrator epa = epService.getEPAdministrator();

        if (ruleName.length() != 0) {
            EPStatement st = epa.getStatement(ruleName);
            if (st == null) {
                return new Result(HttpServletResponse.SC_NOT_FOUND,
                        String.format("{\"error\":\"%s not found\"}\n", ruleName));
            } else {
                return new Result(HttpServletResponse.SC_OK, Utils.Statement2JSONObject(st).toString());
            }
        } else {
            String[] sttmntNames = epa.getStatementNames();
            JSONArray ja = new JSONArray();
            for (String name : sttmntNames) {
                logger.debug("getting rule " + name);
                EPStatement st = epa.getStatement(name);
                ja.put(Utils.Statement2JSONObject(st));
            }
            return new Result(HttpServletResponse.SC_OK, ja.toString());
        }

    } catch (EPException epe) {
        logger.error("getting statement" + epe);
        return new Result(HttpServletResponse.SC_BAD_REQUEST,
                String.format("{\"error\":%s}\n", JSONObject.valueToString(epe.getMessage())));
    }
}

From source file:com.threewks.thundr.view.jsonp.JsonpView.java

private void applyDefaults() {
    if (StringUtils.isBlank(getContentType())) {
        withContentType(MimeTypes.MIME_APPLICATION_JAVASCRIPT);
    }// w  ww  .  ja  v a2  s.  c o  m
    if (StringUtils.isBlank(getCharacterEncoding())) {
        withCharacterEncoding(StringPool.UTF_8);
    }
    if (getStatusCode() == null) {
        withStatusCode(HttpServletResponse.SC_OK);
    }
}

From source file:hr.foi.sis.filters.CorsFilter.java

@Override
public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc)
        throws IOException, ServletException {
    HttpServletResponse response = (HttpServletResponse) sr1;
    response.setHeader("Access-Control-Allow-Origin", "*");
    response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
    response.setHeader("Access-Control-Max-Age", "3600");
    response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With,"
            + " Content-Range, Content-Disposition, Content-Type, Authorization, X-CSRF-TOKEN");

    if ("OPTIONS".equalsIgnoreCase(((HttpServletRequest) sr).getMethod())) {
        response.setStatus(HttpServletResponse.SC_OK);
    } else {//from   w w  w  .j a  v  a2  s .c  om
        fc.doFilter(sr, sr1);
    }
}

From source file:hr.foi.rsc.filters.CorsFilter.java

@Override
public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain fc)
        throws IOException, ServletException {
    HttpServletResponse response = (HttpServletResponse) sr1;
    response.setHeader("Access-Control-Allow-Origin", "*");
    response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
    response.setHeader("Access-Control-Max-Age", "3600");
    response.setHeader("Access-Control-Allow-Headers",
            "Origin, X-Requested-With, Content-Range, Content-Disposition, Content-Type, Authorization, X-CSRF-TOKEN");

    if ("OPTIONS".equalsIgnoreCase(((HttpServletRequest) sr).getMethod())) {
        response.setStatus(HttpServletResponse.SC_OK);
    } else {//from  w w w  .  ja  v  a2  s . co  m
        fc.doFilter(sr, sr1);
    }
}

From source file:cz.cas.lib.proarc.authentication.utils.AuthUtils.java

/**
 * Writes the authentication OK status to the HTTP response.
 * @param response response/*from  w  w  w .j  av a 2s  .c  o m*/
 * @throws IOException failure
 * @see <a href='http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/docs/Relogin.html'>SmartGWT Relogin</a>
 */
public static void setLoginSuccesResponse(HttpServletResponse response) throws IOException {
    response.setStatus(HttpServletResponse.SC_OK);
    response.setContentType(MediaType.TEXT_HTML);
    InputStream res = ProarcAuthFilter.class.getResourceAsStream("loginSuccessMarker.html");
    try {
        IOUtils.copy(res, response.getOutputStream());
        res.close();
    } finally {
        IOUtils.closeQuietly(res);
    }
}

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

public JSONResponse(Object o) {
    this(o, HttpServletResponse.SC_OK);
}

From source file:com.ar.dev.tierra.api.config.SimpleCORSFilter.java

@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
        throws IOException, ServletException {
    HttpServletResponse response = (HttpServletResponse) resp;
    HttpServletRequest request = (HttpServletRequest) req;
    response.setHeader("Access-Control-Allow-Origin", "*");
    response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
    response.setHeader("Access-Control-Max-Age", "3600");
    response.setHeader("Access-Control-Allow-Headers",
            "x-requested-with, authorization, Content-Type, Authorization, credential, X-XSRF-TOKEN");

    if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
        response.setStatus(HttpServletResponse.SC_OK);
    } else {//from  w  w  w  . ja v  a 2s. c o m
        chain.doFilter(req, resp);
    }

}

From source file:com.excella.deploy.agent.core.StatusServlet.java

/**
 * {@inheritDoc}/*from www.jav  a2 s. co m*/
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    log.info("Recieved status request command over http [" + request.getRequestURI() + "]");
    try {
        log.debug("Reporting Status...");
        response.setContentType("text/html");
        response.setStatus(HttpServletResponse.SC_OK);
        PrintWriter writer = response.getWriter();
        writer.println("<h1>Deploy Agent Status</h1>");
        writer.println("<p>");
        writer.println("Everything is Great!");
        writer.println("</p>");
        ((Request) request).setHandled(true);
    } catch (Exception e) {
        log.error("Failed to report Status.", e);
    }
}

From source file:org.craftercms.cstudio.publishing.servlet.StatusMonitoringServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType(MimeTypeUtils.APPLICATION_JSON_VALUE);
    response.getWriter().println("{ status: \"" + statusMessage + "\" }");
    response.setStatus(HttpServletResponse.SC_OK);
}