简体   繁体   English

如何从Java EE应用程序外部化PDF?

[英]How can I externalize a PDF from a Java EE application?

I have a Java EE application, running under WebLogic 10.3.5 and Java 6. I used to have a pdf help file, embedded in my war file, but I need to extract it from there and put it in an external directory (it can be in my same WebLogic domain directory). 我有一个Java EE应用程序,可在WebLogic 10.3.5和Java 6下运行。我以前在war文件中嵌入了一个pdf帮助文件,但是我需要从那里解压缩并将其放在外部目录中(它可以在我相同的WebLogic域目录中)。

I tried to put it in my WebLogic domain and then to < a href > it, but it seems that browsers have limitation and for security reason will not allow to download local file with a href or javascript. 我试图将其放在WebLogic域中,然后再<href>对其进行访问,但是似乎浏览器有限制,并且出于安全原因,不允许使用href或javascript下载本地文件。

This used to work only on a static HTML file saved on my computer but one the HTML page is deployed on the server, it seems not be possible. 这过去只能在我的计算机上保存的静态HTML文件上起作用,但是在服务器上部署了一个HTML页面,这似乎是不可能的。

Any idea how I can externalize my help.pdf file from my war file? 知道如何从war文件中外部化help.pdf文件吗?

Although some application servers allow a Java EE app to reference a file outside the web container, in reality, your web app shouldn't have any knowledge about anything outside the web container, and as you have mentioned, it is indeed a huge security concern. 尽管某些应用程序服务器允许Java EE应用程序引用Web容器之外的文件,但实际上,您的Web应用程序不应对Web容器之外的任何东西有任何了解,并且正如您已经提到的,这确实是一个巨大的安全问题。

Depending on what you are trying to accomplish with this PDF file, if you merely want to expose this file on the web, do what @duffmo said and it will work fine. 根据您要使用此PDF文件完成的操作,如果您只想在Web上公开此文件,请执行@duffmo所说的操作,即可正常工作。 If you want the flexibility to modify this PDF file frequently without recreating the war file again and again, you may want to consider hosting this PDF file in some HTTP web server (Apache2, IIS, etc) and now you reference that link from your web app. 如果您希望灵活地频繁修改此PDF文件而不必一次又一次地重新创建war文件,则可以考虑将该PDF文件托管在某些HTTP Web服务器(Apache2,IIS等)中,现在您可以从Web中引用该链接应用程序。

@limc is right @limc是正确的

you should put this static file outside of Weblogic altogether as a file on an Apache web server 您应该将此静态文件作为Apache Web服务器上的文件放在Weblogic之外

However, in Weblogic there is a feature of virtual directory mapping which allows you to declare a folder outside of the weblogic domain as a content store for any static stuff. 但是,Weblogic中具有虚拟目录映射的功能,该功能允许您将weblogic域之外的文件夹声明为任何静态内容的内容存储。

http://docs.oracle.com/cd/E11035_01/wls100/webapp/weblogic_xml.html#wp1039396 http://docs.oracle.com/cd/E11035_01/wls100/webapp/weblogic_xml.html#wp1039396

This entry goes in WEB-INF/weblogic.xml 该条目位于WEB-INF / weblogic.xml中

<virtual-directory-mapping>      
<local-path>c:/usr/mypdfs</local-path>      
<url-pattern>/pdf/*</url-pattern>      
</virtual-directory-mapping>

You need to put it at the root of your web context, in exactly the same place as HTML pages. 您需要将其放在Web上下文的根目录中,与HTML页面完全相同。 Your web server will be able to find it there. 您的Web服务器将能够在其中找到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM