Transferring files between web applications running in the same Tomcat Instance

I have two web applications running in the same Tomcat Instance. In one of these applications the user will have the ability to upload files such as images and pdf files. 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


Asked by: First Name291 | Posted: 21-01-2022






Answer 1

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.

Answered by: Julian227 | Posted: 22-02-2022



Answer 2

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.

Answered by: Melissa706 | Posted: 22-02-2022



Answer 3

You could shove the files into a shared database... this also lets you store meta data along with them.

Answered by: Chelsea927 | Posted: 22-02-2022



Similar questions

Transferring data from PHP to Java

I have an XML file which I need to parse using PHP and send the parsed data to Java, what are some best practices to accomplish it ?


General Socket Question - Transferring C++ Structs from Java to C++

I have a general socket programming question for you. I have a C struct called Data: struct data { double speed; double length; char carName[32]; struct Attribs; } struct Attribs { int color; } I would like to be able to create a similar structure in Java, create a socket, create the data packet with the above struct, and send it to a C++ socket list...


c# - Strategy for transferring Large amount of data

I am writing my master thesis and is in contact with a digital signage company where im writing about the distribution of large amount of data. I need some ideas or some documented experiences with transfering large amount of data (this is images and video, ~100Mb - ~1Gb - but any data would do, large datasets would give some of the same problems) to multiple clients. Does anyone know of a method i could look into...


java - SOAPUI Transferring Property

I am trying to do a transfer property in SOAP UI 3.6 prof. I am able to work it out properly. The question really is to make it random. What I mean is, in the first SOAP response, there will be a list of results and I want to pick one randomly to transfer it to second request. Is there any way to do it?


java - transferring class JTextArea to main class JTextArea

public class SimpleWebCrawler extends JFrame { static JTextArea _resultArea = new JTextArea(200, 200); JScrollPane scrollingArea = new JScrollPane(_resultArea); private final static String newline = "\n"; public SimpleWebCrawler() throws MalformedURLException { _resultArea.setEditable(false); System.out.println("Please enter the website :"); Scanner scan2 = new Scanner(System.i...


java - Transferring a WHOLE netbeans GUI project

Alright, so for a homework assignment I had to make a simple application with java swing. I used the netbeans GUI builder to do it and it works fine. However, when I zip up the entire folder (Documents\NetBeansProjects\Lesson 7) my professor complains that he doesn't have all the files. What other files could there be? I'm zipping up the whole folder that includes build, nbproject, src, test, build.xml, and manifest.mf. Is...


java - What does BitTorrent and Gnutella uses for bypassing NAT when transferring files?

I´m trying to do a p2p file sharing proto/software in Java. I am interested in learning using socket so, no I will not use JXTA or any kind of API. I read about TCP hole punching, and it may not work on all NAT types. But I can see that Gnutella and BitTorrent always works on every machine/NAT I try. So do they use TCP Hole Punching to initiate a connection between hosts? Also, a code like this would do th...


c# - Transferring user types between domain and service layers in WCF - suggested approaches?

The problem is familiar - when marshalling user defined / domain types through service boundaries, do we simply annotate rich domain objects with [DataContract] attributes (thereby polluting the domain with ServiceModel constructs), or do we implement some sort of DTO process (creating extra work for arguably little benefit)? How are people resolving this conflict? Are there other approaches that...


ftp - 3-rd party component for file transferring via sockets - Java

I study computer-science and right now I am in a middle of Networking course. I need to develop a simple FTP program (client + server). The server listens to port X and waits to connection request. Every client has it's own thread. The server send the client the current list of files it has. The client ask for file and in that point I need to open new socket for the file transferring. When half of the file was sent the cl...


java - Blink jframe in swing without transferring focus

I want to blink my jframe's entry in taskbar but do not want it to get focused. I read about in on net and tried different solutions but none of them worked for me. In my case I have a main jframe which has 2 buttons on click of which 2 jframes are opened. Both jframe listens to some event messages and on receiving of message it should blink if not focused. I have tried following: frame....






Still can't find your answer? Check out these amazing Java communities for help...



Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)



top