ClosedChannelException occurs when i write Japanese PDF binary data to HttpServletResponse OutputStream in Https Protocol

Viewed 28

I am trying to write PDF binary (English / Japanese) to HttpServletResponse OutputStream, this is working fine in HTTP Protocol but where as the same code breaking or throwing ClosedChannelException in HTTPS Protocol only for Japanese PDF (English PDF works fine in HTTPS protocol also) , kindly help me on it, below is my servlet code and configuration

Servlet Code

@Override
    @TraceMonitor
    @ErrorHandling
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
        try {
            if (req.getParameter("inputIdtoTable") != null && req.getParameter("inputIdtoTable").length() > 0) {
                TableEntity tablentity = ordrArrivalDao.getTableEntityFindById(req.getParameter("inputIdtoTable"));
                resp.reset();
                resp.setBufferSize(DEFAULT_BUFFER_SIZE);
                resp.setContentType("application/pdf;charset=UTF-8");
                resp.setHeader("Content-Length", String.valueOf(tablentity.getPdfData().length));
                resp.setHeader("Content-disposition", "inline; filename=" + tablentity.getPdfFileName() + ".pdf");
                resp.getOutputStream().write(tablentity.getPdfData());
                resp.flushBuffer();
                resp.getOutputStream().close();
            }

        } catch (Exception e) {
            e.getStackTrace();
        } finally {

        }
    }

Servlet Configuration in web.xml

<servlet>
    <servlet-name>MyModelClass</servlet-name>
    <servlet-class>com.x.xx.y.model.MyModelClass</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>MyModelClass</servlet-name>
    <url-pattern>/servletName/*</url-pattern>
</servlet-mapping>

Exception Occurs (only in HTTPS Protocol for Japanese PDFs)

java.nio.channels.ClosedChannelException

0 Answers
Related