top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Is it possible to run a local process (normally run from the command line), within a struts web application?

+1 vote
269 views

Is it possible, and if so how, to run a local process (normally run from the command line), within a struts web application.

posted Mar 23, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Runtime.getRuntime().exec("fubar.sh");
I would launch this in a thread so as to not disrupt WebServer from receiving requests/producing Responses http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html

in production you probably want to consider Message Queues Technologies such as JMS/Quartz/MQSeries create JMS message, publish your JMS Queued Message to JMS provider and let JMS run it
http://docs.oracle.com/javaee/6/tutorial/doc/bncdx.html

When building the war/ear and a Task is to be launched Jenkins PostBuildTask is your best best bet http://wiki.hudson-ci.org/display/HUDSON/Post+build+task

If you want to run a command on a client machine? This is known as a virus ;-)
You can use WebWorkers but this is limited to a browser and JavaScript and it has nothing to do with Struts.
http://www.w3schools.com/html/html5_webworkers.asp

answer Mar 23, 2015 by Abhay Kulkarni
Similar Questions
+2 votes

When you have internet facing application , its important not to expose direct object reference on UI to protect security vulnerability(where user can retrieve the unauthorized data by merely changing the primary key). When you are righting the application from scratch there are various ways you can handle it like :-

1) Handling at data layer where query has user id in where class. user id should be picked from session

2) Maintaining the map reference map at server side . Key can be some number generated based on some algo and value will be primary key. Then expose that number on ui . On server side get the value against that key. Even if user manipulate the number corresponding value wont be found and throw an
error. Something like this.

There will be other ways also.

My question is there something of similar kind available in struts 2 where you can annotate the any field with primary key and it does the step 2 for you or any other implementation to abstract primary key. Any ideas?

+1 vote

We are in the beginning of the migration to struts2 and it seems like there will be some period when both frameworks will be active at the same time..the only problem now is accessing the session beans managed by struts2 in struts1 and vice-versa form beans from strut1 mapped in struts2 . Half of the jsp would use struts1 tags and other half struts2 tags. So there should be beans instantiated in both frameworks.

Probably struts2 bean can be injected to struts1 action with struts1 form still accessible as execute() argument, but what about other way? accessing struts1 form bean (not just data, but managed bean) in struts2 execute() ?

+3 votes

I am trying to access a hadoop 1 installation via the hadoop 2.2.0 command line tools. I am wondering if this is possible at all?

From hadoop 1 I get:

$ hadoop fs -ls hdfs://127.0.0.1:9000/
Found 2 items
drwxr-xr-x - cs supergroup 0 2014-02-01 08:18 /tmp
drwxr-xr-x - cs supergroup 0 2014-02-01 08:19 /user

From hadoop 2.2.0 I get:

$ hadoop fs -ls hdfs://127.0.0.1:9000/
ls: Failed on local exception: java.io.EOFException; Host Details : 
local host is: "i7/127.0.1.1"; destination host is: "localhost":9000;

I am trying to find this information via a web-search, but up to now no success.

...