I am trying to create a CSV file dynamically in the user's system whoever uses my Application so that I can write data into it and then import it to an Excel.
Once I am done with my Application, I am deploying the WAR file in the Tomcat Server in the Server system. I am trying to use System.getProperty("user.home") for creating the file in a particular path. But the file is creating in the system where the App is deployed (Server system).
Different users will be using the App in different systems,so how can I get the path for creating a file in the Local Host System (user's system)?
Any help will be appreciated.
Tomcat knows nothing about the user who is opening the web page. Tomcat is using user.home of those user who started the tomcat instance. You should create custom login permissions with session and map your website accounts to local system users.
Related
We have a web application running at this point on Linux and weblogic setup.
There is one local directory /home/doc which stores the files used in our application.
At present, we make a call to this location via
Wls: virtual url mapping and wls:localPath in the weblogic configuration file.
My query is if this directory is pointing to NAS instead of local will this still work?
Also we access this path via our App url like this: https:///root/home/doc
This url is unprotected from the security authentication.
Will there be any impact to this? Can someone please suggest?
Yes it does not matter if the directory is on block storage or NFS/NAS so long as weblogic can read the files it will work just fine.
I am developing web start java application. I need some initial setup files which needs to be transfered from server to client pc and are in .properties file format. I need these files before launching my application. How can I achieve this?
I have developed a website, one of its operation is to read and write data to text files stored at my local machine such as D://test.txt or C://file.txt, but now I am going to host my website at the external server, i mean over the internet use, i wonder where to keep these files that are associated with read and writing operations. At present I am getting an exception file not found if i am using my local machine location. For your information, I am using GlassFish server.
You will want to create a system property on Glassfish, which represents the file path and name. Then upload the file to that location of your choosing on the server where your website application is deployed.
Depending upon your needs, you may find it easier to deploy the file out with your application. Make sure the file is on the classpath, and you can load it using any number of ways.
I have a java desktop application connected to a derby database
the derby database has some dummy data for trial purposes.
The application is packaged together with the database(as embedded derby database).
When the application is installed on the desktop of my Windows 7 OS , I am able to
access the dummy data as expected. However, when the application is installed in the program file folder, I am not able to access the database as well as the data in the database.
Is there any explanation for this?
The "Program Files" folder is not writeable for a standard user (and for a good reason). Do not store any userdata there.
You need to put the database files into a different folder. This is what e.g. %APPDATA% is intended to be in Windows.
You can obtain the value of the %APPDATA% environment variable using the System.getenv() method.
From within Java you can also put it into a sub-directory the user.home directory using System.getProperty("user.home")
we are having a problem with our recently installed web app.
It allows users to upload files and save them to a directory in the OS. We've asked the Security guys to add the websphere user to the target path group, and this path has 770 permissions.
That should do it, if we log in to the machine with the websphere user, we can create folders and files in that path; but our java web app can´t create a directory and it fails.
Unfortunately no exception is thrown, the failing method first checks for this the existence of this directory with File.isDirectory() if it returns false, then it tries to create it with File.mkdirs().
The directory is not created and so a custom error message is displayed to the user. No other clue in the logs.
I've tried to reproduce the problem in my local linux laptop and toying with users and groups, i've seen that changes to permissions do not take effect until a new session is started, but i'm not sure how that affects our deployed java web app and what needs to be done for permissions to be effective.
I'm also sure the files are written with websphere user, since the app has written some files in a different path.
Has anyone faced something similar?
thanks
chown seems to be a solution.
UPDATE:
Another solution is to check the 'file permission policy' for the java client (see).
Java 2 security uses several policy files to determine the granted permission for each Java program.
For the list of available policy files that are supported by WebSphere® Application Server, see Java 2 security policy files.
* The client.policy file is a default policy file that is shared by all of the WebSphere Application Server client containers and applets on a node.
* The union of the permissions that is contained in the java.policy file and the client.policy file are given to all of the client containers for WebSphere Application Server and applets running on the node.
* The client.policy file is not a configuration file that is managed by the repository and the file replication service. Changes to this file are local and do not replicate to the other machine.
* The client.policy file supplied by WebSphere Application Server is located in the profile_root/properties/client.policy.
* If the default permissions for a client (union of the permissions defined in the java.policy file and the client.policy file) are enough, no action is required. The default client policy is picked up automatically.
* If a specific change is required to some of the client containers and applets on a node, modify the client.policy file with the Policy Tool. Refer to Using PolicyTool to edit policy files for Java 2 security, to edit policy files. Changes to the client.policy file are local for the node.
I hope it helps you.