Copy a file on server and make it accessible - java

I have a jersey web service. I am trying to download a file on my hard disk through my localhost Tomcat server.
window.open("D:\\mario.zip");
This line doesn't work due to security reason.
My 2nd try is creating a folder in the project which can be accessible like localhost/myfolder then I put a file there which can be accessed through http.
Now I copy files from a specific folder to "myfolder" so that they can be downloaded.
The problem is: although the files exist in my hard drive, they cannot be accessible through http. Only after I refresh the project in Eclipse. The files can be accessible through http.
Is there any trigger for the server to update its file list?

How do you create "Aliases" in Apache Tomcat?
This is the answer. I don't know much about other solution than creating an "alias" as in Apache server. Olaf Kock's answer would be interesting too if he can be more beginner-friendly.
Further notice, you can find server.xml in your Tomcat server "project" in Eclipse.

Related

Upload WAR file to an FTP server

I've just finished a web project, working with Struts2, and now I want to add this project to my FTP site. The site runs smoothly on Tomcat 8, but I am not sure how to deploy it to an actual site.
How do I add this .WAR file that has .jsp and .xml files to a website? I've tried to just put it in a directory and launch it with fileZilla, and it doesn't work.
What should I do to launch my Struts2 project to my FTP site?
In FileZilla put your user name and password.
In left side will show your machine file
On right side put path of your webapp folder, It will come in mail when you buy any server from hosting providers or ask them.
Upload your .WAR file in webapp folder.
Restart Tomcat.
I assume you need to deploy it again on your FTP site. You need to deploy it into your webapps folder of your server. You may look at this link. This might help you :)

When tomcat redeploy, the previous upload files are missing

I'm writing a website with the function file uploading.
And the Path I save the file is by ServletActionContext.getServletContext().getRealPath("xxxx")
It will save the file to webapps/mywebsit/xxxx
to allow the clients are able to access the data directly by http:// mywebsit/mebsite/xxxxx
the function is ok.
But when it comes to redeploy on tomcat here comes the problem.
When I redeploy by war file.
It seems sorts of remove the all webapps/mywebsit.
And deploy it with the new war file.
And the previous upload files are missing.
Is there anyway I can let tomcat don't remove my file while it's redeploying?
Or I should store files outside the webapps? But how can I let client be able to reach the file?
When tomcat redeploys your application, it will remove it's directory under /webapps/ completely and unpack the WAR from scratch. TI'd recommend keeping your files outside the webapp's directory. You could try using environment variables to point your application to directory you'd like to use, taking care that the user tomcat runs under has appropriate access rights.

Tomcat and web services

Hello I have a set of web services made in JAVA that are made using a Dynamic Web Project in Eclipse.
When i run an instance of Tomcat 6 in Eclipse and deploy the project on the server it works just fine, I am able to find the wsdl File and access it from a php script.
But when I export the Dynamic Web Proyect as a WAR file and deploy it on the webapps file inside the real Tomcat server, and start the server, I have no idea how to find the wsdl file or how to access it from my php scripts, its just not working.
Is there any thing i have to do to get this to work?
You should try to re-download Tomcat.
If you generate dynamic wsdl then . you can find it at URL something like
http://example.com/context/demo.wsdl
It will be easy to answer your questing if you post web.xml and other related xml config file.

guacamole vnc viewer - how to?

i have my tomcat server running, i downloaded the guacamole vnc viewer, and i followed the instructions on : http://guacamole.sourceforge.net/
however when i type :http://localhost:8080/guacamole/ i get error message : http status 404 The requested resource () is not available.
anyone using guacamole, plz can you explain the steps to follow? i moved the xml files and the war file as instructed, but there is this folder: "guacamole-src.tar" where do i unzip it to?
what are the steps to follow to make it work?
thx a lot:)
Once you've copied guacamole.war, start the server and check if a folder /guacamole is created at the same place (that means the server has found your web application and is trying to deploy it).
Also, please check your Tomcat logs.
You don't need to use guacamole-src.tar, that file only contains the project sources, but it is not needed.

new File not found in Webcontent. Need to refresh

Hello i have a java backend running on tomcat. java creates a .txt File that is saved locally in the Webcontent Folder. But the file is not found on the client side, altought it exists on the Webserver. After a refresh of my java workspace the file is found. Is there a way to tell tomcat to refresh / redeploy using java?
greetings!
Tomcat does not see your WebContents folder, but a copy create by the Tomcat server connector. Refreshing updates the copy.
What generates the .txt file? A separate program or code embedded in your web application?
There are a number of cases where the app would have to generate the file to be immediately available to the browser. For example, an image upload window. When the server creates the file from within WTP, it will have to also create the file at the published location where Tomcat is expected to pick it up. Open the server properties, tomcat arguments, catalina root parameter to find out where this location is. When the application is deployed this functionality will need to be disabled, of course.

Categories

Resources