aspose file tools*
The moose likes JSP and the fly likes linux commands from JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "linux commands from JSP page" Watch "linux commands from JSP page" New topic
Author

linux commands from JSP page

shah isha
Greenhorn

Joined: May 01, 2007
Posts: 18
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

Joined: Sep 11, 2006
Posts: 170
You can check out the method Runtime.getRuntime()

Usage :-

Runtime.getruntime().exec("ls");
shah isha
Greenhorn

Joined: May 01, 2007
Posts: 18
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

Joined: Feb 24, 2006
Posts: 6662
    
    5

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 ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Andris Jekabsons
Ranch Hand

Joined: Jan 20, 2004
Posts: 82
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

Joined: May 01, 2007
Posts: 18
@ 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

Joined: May 01, 2007
Posts: 18
@ 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

Joined: Feb 24, 2006
Posts: 6662
    
    5

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

Joined: Apr 19, 2005
Posts: 189
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".
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: linux commands from JSP page