简体   繁体   English

如何在Linux Debian OS中的tomcat Web服务器上部署数据文件

[英]How to deploy a data file on tomcat web server in linux debian OS

I have a web application developed using JSP and Servlet. 我有一个使用JSP和Servlet开发的Web应用程序。 This web application is deployed on server having Debian Linux as OS and The Tomcat version is 5.5.31. 该Web应用程序部署在以Debian Linux为操作系统的服务器上,Tomcat版本为5.5.31。 As this applications required some data files, These data files will be get created automatically when setting are done using a standalone java application. 由于此应用程序需要一些数据文件,因此使用独立的Java应用程序进行设置时,将自动创建这些数据文件。 This application is deployed on another machine. 此应用程序已部署在另一台计算机上。 This setup is done. 设置完成。 As I dont know much about Debian Linux and where my application is goes on it so I have some doubts in deployment of these autimatically generated data files which are as follows 由于我对Debian Linux及其应用程序的了解不多,因此我对这些自动生成的数据文件的部署存在一些疑问,如下所示

  1. As I made the .war file of my web application and deployed it using Tomcat Manager. 在制作Web应用程序的.war文件并使用Tomcat Manager进行部署时。 so I dont know where exactly my application goes. 所以我不知道我的应用程序到底去了哪里。 I dont know the exact path. 我不知道确切的路径。 How do I find it? 我如何找到它?

  2. Is it possible to create FTP for this web application which is deployed on Debian Linux server? 是否可以为此在Debian Linux服务器上部署的Web应用程序创建FTP? I think that if creating FTP is possible then I will directly connect to FTP using my Stand alone Java program and will easily do the creation of the file and other file and directory manipulation. 我认为,如果可以创建FTP,那么我将使用我的独立Java程序直接连接到FTP,并且可以轻松地创建文件以及进行其他文件和目录操作。

If you've deployed a war, the application isn't anywhere on the filesystem as such. 如果部署了战争,那么应用程序就不在文件系统上的任何位置。 Most servers will unpack the war somewhere, but you shouldn't rely on where that is. 大多数服务器将在某个地方展开战争,但是您不应该依赖于那儿。

I can think of several options: 我可以想到几种选择:

  1. getServletContext().getAttribute("javax.servlet.context.tempdir") to get the application's temp directory, then inform you external program of this location and place the file somewhere in there in a know location. getServletContext()。getAttribute(“ javax.servlet.context.tempdir”)获取应用程序的temp目录,然后将该位置通知给外部程序,并将文件放置在已知位置的某个位置。

  2. Arrange for a "know location" outside of the application, such as /tmp/somewhere or /var/cache/your-app/somewhere to place such files. 在应用程序外部安排“知道位置”,例如/ tmp / somewhere或/ var / cache / your-app / somewhere来放置此类文件。 (Note: /tmp is usually cleaned on startup of a linux machine) (注意:/ tmp通常在启动Linux机器时清除)

As for getting the file onto the server from a remote machine: You could get your client to upload the file directly to your webapp (something like Apache HTTPClient will help you there), which means that you could do without the "know location" above. 至于将文件从远程计算机获取到服务器上:您可以让客户端将文件直接上传到您的Web应用程序(例如Apache HTTPClient可以在其​​中帮助您),这意味着您可以不用上面的“知道位置” 。 If you want to do this outside of the application though, I'd avoid FTP (due to security). 但是,如果您想在应用程序外部执行此操作,则应避免使用FTP(由于安全性)。 Instead, I'd go with scp (secure copy). 相反,我会选择scp(安全副本)。

Edit: Reading between the lines a little, you mention "setting" in the data file. 编辑:稍微读两行之间,您会在数据文件中提到“设置”。 If this is a configuration file which is not changed once the app is running, you may find it more convenient to have a "deploy" step on your server which simply takes the settings file and adds it to the war before deploying it. 如果此配置文件在应用程序运行后不会更改,则可能会发现在服务器上进行“部署”步骤更为方便,该步骤只需获取设置文件并将其添加到战争中,然后再进行部署即可。 This is easy enough with "ant war" for example. 举例来说,这很容易做到。 You could then access the file using getClass().getResourceStream(..) or such. 然后,您可以使用getClass()。getResourceStream(..)等访问文件。

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

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