Example usage for java.io PrintWriter write

List of usage examples for java.io PrintWriter write

Introduction

In this page you can find the example usage for java.io PrintWriter write.

Prototype

public void write(String s) 

Source Link

Document

Writes a string.

Usage

From source file:com.sentinel.rest.handlers.AuthFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    LOG.trace("Method: onAuthenticationFailure called.");

    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    PrintWriter writer = response.getWriter();
    writer.write(exception.getMessage());
    writer.flush();/*from w ww.j av a2  s  . c om*/
    LOG.trace("Method: onAuthenticationFailure finished.");
}

From source file:de.knightsoftnet.validators.server.security.AuthFailureHandler.java

@Override
public void onAuthenticationFailure(final HttpServletRequest prequest, final HttpServletResponse presponse,
        final AuthenticationException pexception) throws IOException, ServletException {
    presponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);

    final PrintWriter writer = presponse.getWriter();
    writer.write(pexception.getMessage());
    writer.flush();//from  w w  w .j  a  v  a2s. c om
}

From source file:org.openmrs.module.metadatasharing.web.view.JsonView.java

/**
 * @see org.springframework.web.servlet.view.AbstractView#renderMergedOutputModel(java.util.Map,
 *      javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*from w  w  w. ja v a  2 s . co m*/
@Override
protected void renderMergedOutputModel(@SuppressWarnings("rawtypes") Map model, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    response.setHeader("Pragma", "No-cache");
    response.setDateHeader("Expires", 0);
    response.setHeader("Cache-Control", "no-cache");
    response.setContentType("application/json");
    PrintWriter writer = response.getWriter();
    writer.write(serializer.serialize(getObjectToSerialize(model, request, response)));
}

From source file:org.openmrs.module.metadatasharing.web.view.XmlView.java

/**
 * @see org.springframework.web.servlet.view.AbstractView#renderMergedOutputModel(java.util.Map,
 *      javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*from   ww w  . j a  v a2s  .c  o m*/
@Override
protected void renderMergedOutputModel(@SuppressWarnings("rawtypes") Map model, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    response.setHeader("Pragma", "No-cache");
    response.setDateHeader("Expires", 0);
    response.setHeader("Cache-Control", "no-cache");
    response.setContentType("application/xml");
    PrintWriter writer = response.getWriter();
    writer.write(serializer.serialize(getObjectToSerialize(model, request, response)));
}

From source file:org.wso2.carbon.core.transports.util.MockTryItProcessor.java

public void process(CarbonHttpRequest request, CarbonHttpResponse response,
        ConfigurationContext configurationContext) throws Exception {
    response.addHeader(HTTP.CONTENT_TYPE, "text/html");
    PrintWriter out = response.getWriter();

    out.write("<div id=\"alertMessageBox\" style=\"display:none;position:absolute;z-index: 600;\">\n"
            + "    <!--the message area-->\n" + "    <p id=\"alertMessageBoxMessageArea\"></p>\n"
            + "    <!-- the button area-->\n" + "    <p id=\"alertButton\" align=\"right\">\n"
            + "        <input id=\"alertBoxButton\" type=\"button\"\n" + "                value=\"  OK  \"\n"
            + "                onclick=\"javascript:document.getElementById('alertMessageBox').style.display='none';return false;\"/></p>\n"
            + "</div>"
            + "<link rel=\"stylesheet\" type=\"text/css\" href=\"../css/main.css\" media=\"screen, projection\" />"
            + "<script type=\"text/javascript\" src=\"../js/main.js\"></script>"
            + "<script type=\"text/javascript\">"
            + "wso2.wsf.Util.alertMessage('This function is not currently supported by WSO2 WSAS');"
            + "setTimeout(\"history.back()\",3000)" + "</script>");
    out.flush();/*from  ww w.  j  a v  a  2  s  . c  o  m*/
    out.close();
}

From source file:com.bitranger.parknshop.seller.controller.SellerApplyShopCtrl.java

@RequestMapping(value = "/seller/applyShop", method = RequestMethod.GET)
public void applyShop(HttpServletRequest request, HttpServletResponse response) throws IOException {

    PsSeller psSeller = (PsSeller) request.getSession().getAttribute("currentSeller");

    String message = request.getParameter("msg");

    PsShopApply psShopApply = new PsShopApply();
    psShopApply.setIdSeller(psSeller.getId());
    psShopApply.setMessage(message);//from   ww  w  . ja v a2s .  co m
    psShopApply.setTimeCreated(new Timestamp(System.currentTimeMillis()));

    psShopApplyDAO.save(psShopApply);

    PrintWriter out = response.getWriter();
    out.write("success");
    out.flush();
    out.close();
}

From source file:de.iew.web.view.js.JavascriptConfigView.java

@Override
protected void renderMergedOutputModel(Map<String, Object> stringObjectMap, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    response.setContentType("text/javascript; charset=utf-8");

    PrintWriter writer = response.getWriter();
    writer.write("define(function(){return{");

    writer.write(renderBaseUrlHelper(request));

    writer.write("}});");
}

From source file:org.esigate.servlet.impl.ResponseSenderTest.java

public void testSendResponseAlreadySent() throws Exception {
    MockHttpServletResponse httpServletResponse = new MockHttpServletResponse();
    PrintWriter writer = httpServletResponse.getWriter();
    writer.write("Test");
    writer.close();/*from   w w w. jav  a 2 s . co  m*/
    CloseableHttpResponse httpClientResponse = BasicCloseableHttpResponse
            .adapt(new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK")));
    httpClientResponse.setEntity(new StringEntity("Abcdefg"));
    renderer.sendResponse(httpClientResponse, null, httpServletResponse);
}

From source file:com.parleys.server.frontend.web.ipad.filters.LoginFilter.java

private void writeError(PrintWriter writer) {
    writer.write("{\"error\": true, \"message\": \"Invalid credentials\"}");
}

From source file:com.gu.management.spring.ManagementUrlDiscoveryController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws IOException {

    response.setContentType("text/html;charset=UTF-8");

    PrintWriter writer = response.getWriter();

    writer.write("<html><head><title>Management URLs</title></head><body><h2>Management URLs</h2><ul>\n");
    Collection<String> managementUrls = service.getManagementUrls();
    for (String url : managementUrls) {
        if (!"/management".equals(url)) {
            writer.printf("<li><a href=\"management%s\">%s</a></li>\n", url, url);
        }/*from w  ww . j  a  va2 s  .com*/
    }

    writer.write("</ul></body></html>");

    return null;
}