jQuery in Action, 2nd edition*
The moose likes JSP and the fly likes want to execute dosCommand from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "want to execute dosCommand from JSP " Watch "want to execute dosCommand from JSP " New topic
Author

want to execute dosCommand from JSP

ukb firstname ukb lastname
Greenhorn

Joined: Jun 18, 2013
Posts: 1
Hi,
I want to execute DOS command "net config workstation" from jsp file. When i execute the below snippet from simple java class it is executing and giving me the output. But once i tried to execute this from JSP file or calling a java method where this code snippet is wriiten to JSP file, it is not execting.

final String dosCommand = "net config workstation";
final Process process = Runtime.getRuntime().exec(dosCommand);
final InputStream in = process.getInputStream();
System.out.println(" in length " + in.read());

From the simple java application class i get the in length value 67 but through JSP it is -1.

Any one please help if you have any idea on this.

Thanks,

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60741
    
  65

This is not something you should be doing in a JSP. In fact, modern JSPs should not contain any Java code. Leave the code in Java class.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
Don't get me started about those stupid light bulbs.
 
subject: want to execute dosCommand from JSP
 
Similar Threads
Error with running batch file from Java class
If I Close the Server
Custom Translation step: Possible?
JSP Page Encoding
Base64 encoded file as POST request not working correctly.