Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

linux commands from JSP page

 
shah isha
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

How can i run linux commands from JSP page??

I have written one class which has one method which kills process.

But when i call it from jsp page its not working...

Why so?

Regards,
Isha
 
vanlalhmangaiha khiangte
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can check out the method Runtime.getRuntime()

Usage :-

Runtime.getruntime().exec("ls");
 
shah isha
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for your reply,

I have written the same code in my one java class. Its working too when i run it.

But when i import it in my jsp file and trying to run it on click.. its not working..

Why so??

Regards,
Isha
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by shah isha:
Hi all,

How can i run linux commands from JSP page??

I have written one class which has one method which kills process.

But when i call it from jsp page its not working...

Why so?

Regards,
Isha


Why exactly are you killing processes from a JSP page ? That is not what a JSP is meant for. Can you post some code ?
 
Andris Jekabsons
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your JSP page work? If you add some HTML code to it, do you see it on the screen?
Does calling the class from JSP page work? If you add some println statements in your class, do they get printed out (most likely to your web container's log file).
If that works, maybe there are some security restrictions on JSP (kind of like on Applets when they're not allowed to do everything what a regular Java application can)?
 
shah isha
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ John Meyers

Hi,

I am developing administration part of network management.

In which admin can view process running on some computer and can kill it by clicking on button. This coding is done in jsp.

Regards,
Isha
 
shah isha
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Andris Jekabsons

Hi,

Ya my code is running perfectly fine.
In fact i have another function which is not having any linux commands in the same class where i have kept function to kill process.

That function is working from jsp but not the one which is killing process.

Regards,
Isha
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it does not work in a JSP, call a servlet that will kill the process for you and then redirect you to a JSP page that dynamically lists down active processes. Do you see any error stacks when you use the code in a jsp ?
 
vu lee
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder whether you had efficient priviledge to run kill command. Before running killing command in jsp, would you add code to check what your userid was? eg. "whoami".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic