Example usage for com.liferay.portal.kernel.servlet UncommittedServletResponse UncommittedServletResponse

List of usage examples for com.liferay.portal.kernel.servlet UncommittedServletResponse UncommittedServletResponse

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.servlet UncommittedServletResponse UncommittedServletResponse.

Prototype

public UncommittedServletResponse(HttpServletResponse httpServletResponse) 

Source Link

Usage

From source file:com.liferay.util.axis.AxisServlet.java

License:Open Source License

@Override
public void service(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

    try {//from w ww.ja va 2 s .c  o  m
        if (!_ready) {
            return;
        }

        StringServletResponse stringResponse = new StringServletResponse(response);

        super.service(request, stringResponse);

        String contentType = stringResponse.getContentType();

        response.setContentType(contentType);

        String content = stringResponse.getString();

        if (_fixContent) {
            if (contentType.contains(ContentTypes.TEXT_HTML)) {
                content = _HTML_TOP_WRAPPER.concat(content).concat(_HTML_BOTTOM_WRAPPER);
            } else if (contentType.contains(ContentTypes.TEXT_XML)) {
                content = fixXml(content);
            }
        }

        ServletResponseUtil.write(new UncommittedServletResponse(response), content.getBytes(StringPool.UTF8));
    } catch (IOException ioe) {
        throw ioe;
    } catch (ServletException se) {
        throw se;
    } catch (Exception e) {
        throw new ServletException(e);
    } finally {
        try {
            ThreadLocal<?> cache = (ThreadLocal<?>) _cacheField.get(null);

            if (cache != null) {
                cache.remove();
            }
        } catch (Exception e) {
            _log.error(e, e);
        }
    }
}