sanjay_thakur
asked on
regd Java and scripting
Hi
I have a java applet
I have a java object called "Volume" which has certain
attributes like
Name
WWN
Capacity
Now I want to automate the process of creating these
volume objects by reading these properties from some file
say " volume.txt"
For example If have a right click menu option
"import" I could read the properties from "Volume.txt"
and create a new volume object
Also the user could change the values in this file
that is user could edit this file
If I use a simple .txt file for this then I would need
to parse this file which gets complicated
I have looked into creating PDF files from a java application.
But I am not sure there is an easy way to parse these
PDF files or edit them
What could be a good way to do this?
How would I parse the txt files?
Is there any tool available to do this
Please share if there is any other approach
like using a simple scripting language
Thanks
I have a java applet
I have a java object called "Volume" which has certain
attributes like
Name
WWN
Capacity
Now I want to automate the process of creating these
volume objects by reading these properties from some file
say " volume.txt"
For example If have a right click menu option
"import" I could read the properties from "Volume.txt"
and create a new volume object
Also the user could change the values in this file
that is user could edit this file
If I use a simple .txt file for this then I would need
to parse this file which gets complicated
I have looked into creating PDF files from a java application.
But I am not sure there is an easy way to parse these
PDF files or edit them
What could be a good way to do this?
How would I parse the txt files?
Is there any tool available to do this
Please share if there is any other approach
like using a simple scripting language
Thanks
I agree with the above. You'll have to store the file containing the properties in the applet's codebase or you won't be allowed to write to it (or read from it for that matter).
Yes, it's java.util.Properties and then use the load() Method...but this won't work for applets...
I am not really sure why you want to store thes properties in a file...take a DB for saving user input on the server and use these entries for generating your volume objects. You could even use EJBs for the volume objects with CMP...Your applets could connect to them using RMI-IIOP and the Volumes home object would like like a local instance...
For PDF manipulation/generation you can use XML and XSL-FO...it works fine, used it in my last project. For an implementation of XSL-FO and a free processor see http://xml.apache.org/fop/index.html
Have fun!
Mirko
I am not really sure why you want to store thes properties in a file...take a DB for saving user input on the server and use these entries for generating your volume objects. You could even use EJBs for the volume objects with CMP...Your applets could connect to them using RMI-IIOP and the Volumes home object would like like a local instance...
For PDF manipulation/generation you can use XML and XSL-FO...it works fine, used it in my last project. For an implementation of XSL-FO and a free processor see http://xml.apache.org/fop/index.html
Have fun!
Mirko
ASKER
Lets say there is some file on the clients harddrive or A: or anywhere called "Volume.txt"
In the Applet there is a button called "export from"
When the user clicks on this button ,a file chooser is loaded and this file "Volume.txt" is selected
The Applet has to parse this file and find if the values needed to create a new volume object exist.
If the Applet could read and parse this file and find enough information to create a new volume object
It will ; else return an error message
Now the problem is that this "volume.txt" could have any thing.
Even if this file was "Volume.properties" with something like
name:volume
capacity:100 gb
There are problems
This "Volume.properties" will not essentially be in the applets codebase
If this file is not in the applets codebase can the applet still access this file and read from it?
I doubt.
Thus I need to stick with some .txt or .xml file
and then the parsing gets involved
for mirko
I will look into and see if I could use xml
Thanks all of you
In the Applet there is a button called "export from"
When the user clicks on this button ,a file chooser is loaded and this file "Volume.txt" is selected
The Applet has to parse this file and find if the values needed to create a new volume object exist.
If the Applet could read and parse this file and find enough information to create a new volume object
It will ; else return an error message
Now the problem is that this "volume.txt" could have any thing.
Even if this file was "Volume.properties" with something like
name:volume
capacity:100 gb
There are problems
This "Volume.properties" will not essentially be in the applets codebase
If this file is not in the applets codebase can the applet still access this file and read from it?
I doubt.
Thus I need to stick with some .txt or .xml file
and then the parsing gets involved
for mirko
I will look into and see if I could use xml
Thanks all of you
ASKER
Hi all
Is it possible to read the Properties file
if it is not in the Applet's codebase
For example
I create a new Volume Object with properties
"name==Volume "
"wwn ==192.168.."
now I want to export these values in a file "MyVolume.properties"
now The user can create multiple new volumes
by saying "export" and exporting "MyVolume.properties"
The application will read from "MyVolume.properties"
and create new volume object
Please let me know if this is a possible ?
Thanks all
Is it possible to read the Properties file
if it is not in the Applet's codebase
For example
I create a new Volume Object with properties
"name==Volume "
"wwn ==192.168.."
now I want to export these values in a file "MyVolume.properties"
now The user can create multiple new volumes
by saying "export" and exporting "MyVolume.properties"
The application will read from "MyVolume.properties"
and create new volume object
Please let me know if this is a possible ?
Thanks all
>>Is it possible to read the Properties file
if it is not in the Applet's codebase
Yes, but you'll have to sign it. Check out this excellent article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1215-security.html
if it is not in the Applet's codebase
Yes, but you'll have to sign it. Check out this excellent article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1215-security.html
Yes, the further capabilities would go outside of the applets sandbox. Applets are designed by default to work ONLY within the web-browser once deployed. Here is some further information to accompany the above artice: http://java.sun.com/sfaq/
tom
tom
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi all,
I will try signing the applet and
reading/writing from the properties file
Please have patience.
I will try this and let you know if I am stuck somewhere
Is there is any other workaround to do the same
without signing the applet?
Just a thought!
Thanks all
I will try signing the applet and
reading/writing from the properties file
Please have patience.
I will try this and let you know if I am stuck somewhere
Is there is any other workaround to do the same
without signing the applet?
Just a thought!
Thanks all
ASKER
I have not yet tried signing the applet but I guess
that is not a part of this question
Thanks for all the help
that is not a part of this question
Thanks for all the help
I think the properties object would be best for you. You are already calling them properties. Take a look in the java.util package for the class. The Javadoc gives it straightforward on how to implement it.
Tom