Originally posted by peter brews:
I am new to ejb and I came to know that usage of the java.io package is forbidden in the spec but in my method implemented in ejb bean i need to write to a external file.And a shell script is then executed which reads this file and does furhter processing.Is there some other way to achive this result ans will there be problems if I use the following code.Any suggestion in this matter is highly apprecaited. Following is the piece of code.. from my method <html> <body>
try
{
PrintWriter pw=new PrintWriter(new BufferedWriter(new FileWriter(new File("c:\\testdata.txt"))));
pw.print("aaaaaa");
pw.print("bbbbbbbbbbbbbbbb");
pw.prnt(name);
pw.print(seqid);
pw.close();
}
catch(IOException e)
{
e.getMessage();
}
and then i am using following piece of code to run shell script from that method in ejb
try
{
String command = "sh /export/home//submitData.sh " + currentfile ;
Process p = Runtime.getRuntime().exec(command);
}
catch(Exception e)
{}
</body> </html> Thanks, peter
Process p = Runtime.getRuntime().exec(command);
Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Originally posted by peter brews:
Thank you all for your helpful replies.I code that i had mentioned i in my EJB actually works on my local machine ,but not sure if it will work when multiple users from diffrent systems will call that method.
1. I also wanted to know if the restriction is for security reasons only.
2. Will it be better if i put all this code in seperate java class and call that class in EJB.Does method should be static .If not ,how do i instantiate a class in EJB.
for eg.
I would write a class UtilityMethods.java an will define methods in that say writeData.
Then i will call this method as UtilityMethods.writeData and i will pass the data as string parameter to this method.
3.In most of other mymethods that were defined in EJB i am using url connection to pass and get information .Will there be any problem with that too?
4.Where can i get more details about EJB's.
Thanks,
pete
Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.