I have a server that runs on the following url.
http://localhost:8080/
I have JNLP file inside the tomcat folder and hence i can access it by
http://localhost:8080/abc.jnlp
or by the server ip
http://public-ip.org./abc.jnlp
Now the problem is i have a file that can be opened with the jnlp file. I want to pass that file as the parameter. So what i did was:
#RequestMapping(value="showjnlp",method=RequestMethod.GET)
public void showJnlp(){
Process p=RunTime.getRuntime().exec("javaws -open fileName abc.jnlp");
}
Now if i do this the file opens in the server computer where the war file hosted. I want to open the file in the client side. Anyone who knows how to open the file that resides in the server that can be passed as the parameter to the client side or be opened in the client side computer?
If you can link up the jnlp as a web page to the client it will download into the client side machine and run there.
Related
My Springboot app is installed on one server and I've created a separate server (File Server) for images. Both servers are AWS EC2 instances.
So my goal is to write the image-files onto the File Server and anyone can read or access those files via HTTP protocol.
Apache HTTPD server is installed on the File Server. However, I cannot write the files on the File Server.
I'm getting "IOException/FileSystemException - Network path not found".
I've also installed FtpServer and I can upload/write files there. But then I cannot access the files from the internet using the HTTP protocol.
Code:
String path = generateFilePath(attachmentRequest); //--> //X.X.X.X/file-uploads/bfdec95a-d730-46b4-a835-d0f85a9bc0cc.jpg
File file = new File(path); OK
if(!file.exists())
file.createNewFile(); //Exception --> FileSystemException: \\\\X.X.X.X\\file-uploads\\80ae9bd7-816e-4544-85d3-fd10679adb7d.jpg: The network path was not found.
Files.write(Paths.get(path), attachmentRequest.getFile().getBytes());
Hi I am in the process of creating a web application with jsp/javaservlet. The problem I have is opening a file that is in a different directory than my current java class. I need help to understand why it is not picking up the directory.
Note I am just creating the program on localhost until it is done then I will export it into a .war file and set the permissions with file zilla or linux commands.
I got my file location string from running my Index page and copying it from the address bar.
My Code:
Object obj = parser.parse(new FileReader("http://localhost:8080/Practical_3_JSP/inc/Data/MyData.json"));
The Result:
HTTP Status 404 -
The requested resource is not available.
Path Map:
Note I have tried:
"http://localhost:8080/Practical_3_JSP/inc/Data/MyData.json"
Image Location: http://postimg.org/image/xcu5y82vb/
I have created logs for my project in a log file. I have provided the location of log file as 'logs/LogFile.log' in the java code. When run on a local server(Tomcat or Websphere), a new folder named 'logs' is created in the classpath of the server and i can find the 'LogFile.log' with logs in it.
Now my project is converted to EAR and it is up in the Dev Server. Where will my log file be created? How can i see those logs?
For a local server, the logs will be appended in the destined log file, which will be in the server installed directory or a remote user created directory.
In case of a remote server, say Unix server, the logs will be generated in the specified location inside the server. We need to login to the unix server via putty or Techtia and can view the logs in the specified locations.
I have a self signed applet running in the browser, this applet should create a directory on the client machine using this code.
boolean success = (new File("myDir")).mkdirs();
if (!success) {
System.err.println("Directory creation failed");
}
However, when I run it in the browser (under Apache) and after accepting all the security warnings I can't find myDir directory on my machine.
Am I doing something wrong?
I guess you are not looking at the right place...
Given your code snippet, this directory will be created in the current working directory. To be sure where that is on your machine just try to see what the following code gives out :
System.out.println(System.getProperty("user.dir"));
You're not giving it an absolute path so it's creating myDir in the working directory that the browser runs it in, probably a temp dir, or even a "sandbox" area in some browsers.
Because you run applet in sandbox, so You cannot access into user machine resource.
Please see document:
Applet security
File dir = new File(System.getProperty("user.home")+"\\Desktop\\" + svc);
dir.mkdir();
File f;
f = new File(System.getProperty("user.home")+"\\Desktop\\" + svc
+ "\\" + logFile + "_" + System.currentTimeMillis()
+ ".txt");
I am using this code to store the files in the user(client) machine.But it is storing the files in the server machine.Can anyone help me on this? I have deployed my war file in unix server.
Saving a file on a client machine from software running on a server is not as simple as that.
Servers do not have direct access to the file system of any client - it would be very insecure if that were the case.
The simplest way to do this is by making the server return a web page with a link which the user can click to download the file.
You could also do something more complicated, for example write an applet that downloads the file (using some file transfer protocol) and saves it in the local file system. The applet would need to have the appropriate permissions (by default, applets cannot access the local file system).
Seems like this code is part of a Web Application Server Side. In this case System.getProperty("user.home") will return Server's home directory.