Solved

regd Java  and scripting

Posted on 2002-04-25
10
163 Views
Last Modified: 2010-03-31
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













0
Comment
Question by:sanjay_thakur
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 7

Expert Comment

by:tomboshell
Comment Utility
If you use the properties object and store the data with matching pairs you could do it quick and easy.  It works like an ini data that most everybody is familar with.  It would only require that your data is in a format like "key=value" then you would make the call to load the data, and could use each set like a hashmap.  

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
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
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).
0
 
LVL 1

Expert Comment

by:iartmirko
Comment Utility
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
0
 
LVL 4

Author Comment

by:sanjay_thakur
Comment Utility
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











0
 
LVL 4

Author Comment

by:sanjay_thakur
Comment Utility
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



0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>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
0
 
LVL 7

Expert Comment

by:tomboshell
Comment Utility
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
0
 
LVL 7

Accepted Solution

by:
tomboshell earned 50 total points
Comment Utility
oh ya, here it the link to the java tutorial on the security manager to continue the further accompanying information.  
http://java.sun.com/docs/books/tutorial/essential/system/securityIntro.html
0
 
LVL 4

Author Comment

by:sanjay_thakur
Comment Utility
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
0
 
LVL 4

Author Comment

by:sanjay_thakur
Comment Utility
I have not yet tried signing the applet but I guess
that is not a part of this question

Thanks for all the help
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now