So a bit of background I have a surface level understanding about Tomcat WAR/Java files but I am helping out the programming team as I am taking over managing our Linux servers.
We are utilizing Apache Tomcat 8.5 and we currently have a WAR file that has a database login xml file. We would like to pull out the xml file into its own directory but I want to secure it down to make sure it can only be accessed from the WAR files on the server and not directly by url.
(edit) XML outside of a war file not from within
I'm open to any idea and any form of implementation.
Related
This question already has an answer here:
Deploying WAR FILE in Microsoft Azure Web App
(1 answer)
Closed 5 years ago.
I am attempting to upload a War file of a web service to Azure, running tomcat 8.
I have the war file in the relevant webapps folder on onedrive, however the deployment consistently fails, and frustratingly it does so without an error message.
I'm pretty sure that if I can't use a method involving uploading the binary file to Azure, I cannot use Azure. When using repositories like github, the build would fail due to reference issues, so I believe that is not an option.
Unfortunately I must use Azure, I'm aware that with other services like AWS I'd be done in 5 minutes as you can directly upload without any Microsoft (tm) hassle.
Normally, there are 4 ways to deploy a war file on Azure Web Apps: FTP, repository like Github/BitBucket or OneDrive/Dropbox, Kudu Tool, Azure Toolkit for Eclipse/IntelliJ.
First of all, you need to know File structure on azure. The Java war file must be deployed at the directory webapps under the wwwroot path of Azure Web Apps. You can access the Kudu tool url https://<your-webapp-name>.scm.azurewebsites.net/DebugConsole to lookup it.
Using FTP for deployment, you can refer to the Kudu wiki page Accessing files via ftp to know it, and set the FTP user & password via Azure portal as below.
Using repository like GitHub, you can refer to the Kudu wiki page Deploying from GitHub to know it. Please first make sure the file structure on GitHub repository as the same as its under your wwwroot directory, as below.
A convenient and fast way is using Kudu tool to drag & drop your war file into the webapps directory, as below.
If you had installed Azure Toolkit for Eclipse/IntelliJ, you can refer to Deploy Java Web Apps to Azure using Eclipse or IntelliJ: Deploy Java Web Apps to Azure to do it.
Hope it helps. Any concern, please feel free to let me know.
Quick note that gave me a lot of frustration to figure out. If you use ftp via a client (I use FileZilla for it), think about this:
Place the .war file under: site > wwwroot > webapps > [Place .war file here].
Do also change the .war file name to: ROOT.war
It has to be that name for the system to deploy it. At least for me, the GitHub integration is not working, so I use this ftp method.
The deployment via ftp can take several minutes to be deployed and running.
I am trying to deploy my java web application to Azure using FTP. Is the .war file enough to be uploaded? Or all the project files have to be uploaded?
I believe that .war file is enough, because in that file you have everything that your java web application need, like the java classes, servlets, static web pages, etc, as you can see in this example, opening the war file:
war file
In fact, when we use, for example, the Tomcat server, that's the only thing that the server use for running the web application.
I hope I have helped you!
I have developed a JAVA webstart application using JNLP,am planning access jar files related jnlp from the outside webapp folder how to access those jar files.
jar files related jnlp from the outside webapp folder
Jars in the web app. directory are never meant for client distribution. They stay on the server and are protected.
A Java Web Start app. obviously needs to download all the Jars and related resources to the client, so every one of those resources must be available by URL on a public part of the server. Always make sure you can fetch the resource (Jar, JNLP, icons etc.) using a direct link in your favorite browser. If it does not allow it, neither will it work in JWS apps.
I am working on a feature where i have to provide a direct link to download certain files. all my files are in htdocs folder and i want to provide a direct link to download them like
webapp.com/files/file1.avi
could write a servlet and send the user a file.I know how to do it.
The other way is that if i directly go to webapp.com/files i should be able to see all of the files present in the directory. How do i do that?
do i have to make any server config changes to achieve it?
the webapp is running on Apache tomcat and jdk 1.4
You can directly serve your static content from tomcat(if it is your app server) root directory. I assume other app/web servers will have a static content directory as well.
I'm working on a jsf2 web application and i need to upload files to a folder in my webcontent and keep them permanently, I used the technique that is mentioned in JSF FileUpload Directory and i could upload to wtp... folder's subfolder, but as BlueC said it get lost when tomcat restarts, is there any way to do that?
You can store the files in a Database using a BLOB field. It will depends of how you are implementing the persistence layer of your application but in the Java side usually you will implement this field as byte[]. So it will be comfortable for download or display the file.
You can upload the files to a certain directory/ default directory and then manually copy the files to a secured folder that is outside of the deployment directory and application server installation (yes you can do that).