Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Run a Bat File from JSP

843840Feb 14 2008 — edited Feb 15 2008
Hi to all, i been finding almost all my java answers in this forum, so thanx to all of you who answer

Yesterday i was looking how to run a bat file form a JSP page, i found some code, and i use it, bur the JSP seems to run it but doesnt do anything, i took those lines and copy to a stand a lone java class and it did launch the bat file, i dont know if this is a matter of security.. well here is the code is very simple

the bat is in the machine on directory c:\clases
the bat is called Reinicia.bat

and the JSP page code:

<%@ page contentType="text/html; charset=iso-8859-1" language="java" %>
<%!
// Declaraciones de clase.
String[] command = { "cmd.exe", "/C", "Start", "C:\\CLASES\\Reinicia.bat" };
%>
<%
// Declaracion secuencial de instruccciones de la clase java del jsp.
Process child = Runtime.getRuntime().exec(command);
%>
<HTML>
<BODY>
Si se ejecuto
</BODY>
</HTML>

when i run the page i only get -->Si se ejecuto

no error code and no bat was launched

hope some one can help me

Ricardo
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2008
Added on Feb 14 2008
4 comments
1,391 views