java hide url response servlet

时间:2017-03-08 15:42:45

标签: java servlets

我有一个扩展javax.servlet.http.HttpServlet的Servlet,它的主要目的是生成PDF并将其作为目标_BLANK req发送给客户端。它运作良好,但我遇到的问题是我需要隐藏整个网址,或者至少隐藏域名部分...我已经在网上搜索了很多内容但仍然无法找到确切需要任何人....这是编写PDF的方法:

private void outPdf(String pdfName, HttpServletResponse response, ByteArrayOutputStream baos) 
                                                        throws IOException {
        //setting some response headers
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control", 
                            "must-revalidate, post-check=0, pre-check=0");
        response.setHeader("Pragma", "public");
        //setting the content type
        response.setContentType("application/pdf");

        //
        response.setHeader("Content-Disposition","filename="+pdfName);

        // the contentlength is needed for MSIE!!!
        response.setContentLength(baos.size());
        // write ByteArrayOutputStream to the ServletOutputStream
        ServletOutputStream out = response.getOutputStream();
        baos.writeTo(out);
        out.flush();
}

有可能吗?提前谢谢....

0 个答案:

没有答案