This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Getting started with Java programming language and have Ashish Sarin & J Sharma on-line!
See this thread for details.
Win a copy of Getting started with Java programming language this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Execute linux command in java and display output to html table  RSS feed

 
Harris Marfel
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have jsp code "df -h" for display disk information on the website. How i can show the output to html with table? Bellow the code:


when on linux i execute "df -h" it showing like bellow:

But at html i got like bellow:

how i can fix it? or what code that i need to change?

Thanks before.
 
Dave Tolls
Ranch Hand
Posts: 2413
25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First off, don't do this in your JSP page.
Debugging a JSP page is a pain.
It's also not the JSP's responsibility to get data...it's there to display it.

Write a class that can pull this data out and create an array of objects that represent each row (for example).
That way you can test that class in isolation.

When that works then call that class from a servlet to get the List<YourObjects> and forward them to the JSP for display.

Your client will make a request to the servlet, not the JSP (which should be hidden from the client anyway).
 
Ricardo Marzano
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that this is impossible. You try to list this output to an array. One time in long past ago, I was forced to made something like this but at "the other OS" if you understand me. So, a command for list folders (dir) only show the first line. Nothing more. And I abandoned this project (... course I was fired but this is other history...). To conclude: dosen't work. Regards. Ricardo
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!