This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes System properties (separator) in a web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "System properties (separator) in a web application" Watch "System properties (separator) in a web application" New topic
Author

System properties (separator) in a web application

Ramaswamy Srinivasan
Ranch Hand

Joined: Aug 31, 2004
Posts: 295
There is this web application. I am currently working on setting up the development environment for the same.
I encounter the following problem.

1. At certain stage during the application start-up, the app reads some HTML template file.
2. To do this, it opens the "resource as a stream".
3. Directory path is being read from the configuration file.
4. File name is then appended to the path, after concatenating the "java.io.File.separator" character.
5. Once we do this, the returned value (path) ishaving the following problem

Should have been: \WEB-INF\pages\templates\en\file.html
Is now looking as : \WEB-INF\pages\templates\en/file.html -- value returned after appending the separator.

Obviously, this results in a NullPointerException. According to the Java API spec, java.io.File this is the value of a system property. However, System.setProperty() did not work.

Is there any way I can modify the system property to change the separator? Please let me know, if there's any other way to solve the problem. Thanks in advance!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I thought resources were supposed to be on the classpath--why not just open it as a file if it's not on the classpath?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: System properties (separator) in a web application