简体   繁体   English

在同一Tomcat实例中运行的Web应用程序之间传输文件

[英]Transferring files between web applications running in the same Tomcat Instance

I have two web applications running in the same Tomcat Instance. 我有两个在同一个Tomcat实例中运行的Web应用程序。 In one of these applications the user will have the ability to upload files such as images and pdf files. 在这些应用程序之一中,用户将能够上载诸如图像和pdf文件之类的文件。 I would like the uploaded files to be available to the second application. 我希望上传的文件可用于第二个应用程序。

Is there a best practice for such a scenario? 这种情况有最佳实践吗? Or just a pointer to a technology would be fine. 或者只是一个指向技术的指针就可以了。

I considered using web services but wondered if it was overkill. 我考虑过使用网络服务但是想知道它是否有点过分。

Thanks Vincent 谢谢文森特

Cheap, bad answer - have both applications softlink to a shared directory. 便宜,错误的答案 - 将两个应用程序软链接到共享目录。 This has the benefit of being stupid-simple to do but has evil transactional-type issues. 这样做的好处是愚蠢简单,但有恶意的事务类型问题。 Since you say that only one application is changing the data, and the other is read-only you might be able to get away with it, as long as the second app can't observe files in a partially created state. 由于您只说一个应用程序正在更改数据,而另一个应用程序是只读的,因此只要第二个应用程序无法观察处于部分创建状态的文件,您就可以使用它。

Using a db is transactionally safe but is going to be pretty unpleasant as the files get larger. 使用db在事务上是安全的,但随着文件变大,它会非常不愉快。

I'd say it depends on how robust you need the file storage to be, and how transactional. 我会说这取决于你需要文件存储的强大程度,以及如何进行事务处理。 The simplest way would be a shared directory that's on the classpath of both apps. 最简单的方法是在两个应用程序的类路径上的共享目录。 A database would be a more robust, but more complex, solution. 数据库将是一个更强大但更复杂的解决方案。

您可以将文件推送到共享数据库中......这也允许您将元数据与它们一起存储。

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

相关问题 将文件保存到在同一Tomcat实例中运行的另一个Web应用程序(不起作用) - Saving files to another web application running in the same Tomcat Instance (Not working) 如何在同一JVM中运行的多个应用程序(Web或ejb)之间共享实例? - How to share an instance between multiple applications (web or ejb) running in the same JVM? 在同一tomcat上运行的两个应用程序 - two applications running on the same tomcat 两个Web应用程序之间的会话共享:tomcat - Sessions Sharing between two web applications : tomcat 在单个tomcat实例上部署两个几乎相同的应用程序 - Deploying two almost same applications on single tomcat instance 两个 web 应用程序共享的 JAR 是否可以登录到 Tomcat 中的同一文件? - Can a JAR shared by two web applications log to the same file in Tomcat? Tomcat在哪里存储Web应用程序使用的txt文件 - Where does tomcat store txt files used by web applications 在Web应用程序中公开jar文件中的资源(Tomcat7) - Exposing resources from jar files in web applications (Tomcat7) 同一Tomcat服务器上的两个应用程序之间的双向SSL - Two-way SSL between two applications on the same Tomcat Server 通过序列化在应用程序之间传输Java类 - Transferring a Java class between applications via serialization
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM