Hello,
I'm just starting with J2EE, so I hope you will bear with a very ignorant question. I have a legacy website which I would like to reimplement using some sort of MVC pattern. The site runs ksh scripts, and reads the resulting files, and the new site must do the same.
Can an EJB make calls out to the shell? How do I go about this? (I.e. is there anything special that I should know for it to work within J2EE?)
Many thanks!
Roger Pearse
We can not call your shell scripts from your EJB. If it is manditory for your requirement you can Use struts frame work for your site. This Frame work will follow MVC 2 Design pattern and from Action class you can call Shell script like bellow
Process someAppProcess; //Handle to the process
try
{
someAppProcess = Runtime.getRuntime().exec(
}
catch(java.io.IOException e)
{
//Handle an IOException here.
return;
}
after getting script results put those results as per your wish. Some best practices are hold results in collection object, prepare DTO and pass it to the middle tier, means pass that DTO to Any session bean (EJB) from that middle tier you can communicate with the database.
Hope you have clear understading about MVC. If you are not willing to use Struts frame work you can write that code in ur Servlet also.
Hope this will help you and all the best for your site improvements :)