File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

execute the wget command or get output of url

 
laura mccord
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a wget command that I want to execute from a jsp page: "wget localhost:8080/myApp -q -O -"

I tried running the command from jsp using this method but it didn't work:


Then I tried using this method I found:



Any suggestions?

I would like to get the contents of a given page. In the big picture, what I want to accomplish is that I have a cluster of https servers under a dns and I want to monitor if a given server is functioning by finding a string from the wget response. So the jsp page will be running from each server and I'll have a fail/pass response from each jsp page that will be used to monitor.

Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why use wget? The JSTL <c:import> action will suck in the contents of another URL without all that mess and bother (and without polluting the JSP page with obsolete scriptlet code).
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. If you don't want to display the result, this shouldn't be in a JSP page at all, but in a servlet. JSPs are for views, not processing.
 
laura mccord
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I see. Thanks for the advice.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if you decide to do this in a Java class (servlet or delegate) there are still easier ways than wget. Look into the classes in java.net, or packages like HttpClient.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic