๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.lenguajes.java
Article #696

Re: hola mi problema es con JSPs, ejecucion de un exe y servlets

#696
From: Intruder_Inside
Date: Wed, 17 Jan 2007 23:59
82 lines
3977 bytes
Bueno en realidad creo que lo mas dificil ya lo tienes y es ejecutar el
exe, por lo tanto determino que tu server es una maquina windows, por
que para linux tendrias que hacer un sh, dices que ya tienes como
ejecutar el exe, pero lo tienes en un programa con main, bueno entonces
que tienes que hacer para pasarlo a un bean, o un servlet ->

packege mipp.exe   // no se te olvide empaquetarla
import java.io.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;

public class Ejecutar{

public static void correrExe() {
Runtime run = Runtime.getRuntime(String param); //puedes enviar un
parametro con el path a ejecutar ej: c:\\uno.exe
try {
Process pp=run.exec(param); // o como es un boton que siempre te
ejecuta lo mismo colocar aca el path
}
} catch (Exception e) {e.printStackTrace();}

}

tambien puedes enviarlo por el request y rescatarlo con
request.getParameter("param");



en el jsp entonces tienes que crear una instancia de la clase , no se
te olvide importar el paquete
<%   Ejecutar  miBean= new Ejecutar  ();
      //  miBean.correrExe(algun objeto de la pagina.value ) // con
parametro , que seria el path
      miBean.correrExe() // en caso de que decidas hacerlo sin
parametro

%>


no hay manera de que se ejecute exactamente cuando presiones el boton,
entonces lo que tienes que hacer es enviar  el formulario y validar si
se envio el boton y asi ejecutar el metodo.

mas o menos algo asi.

<%
if(request.getParameter("boton"))
 miBean.correrExe()
%>


Espero hacber resuelto tu inquietud.

off-topic:
Este grupo es de java en general, puedes plantear tus preguntas en
nuestro grupo que se encarga de java con programacion web estructurada:


http://groups-beta.google.com/group/jwebprogramming



Victor Oรฑate A.
Ingeniero de Sistemas
Google Groups Beta
Web Programming with Java
Visitanos!!


On Jan 3, 11:12 pm, "omm79" <omm1...@gmail.com> wrote:
> BIEN AMIGOS DEL GRUPO, PUES TENGO LO MAS IMPORTANTE PARA MI QUE ES LA
> EJECUCION DE UN EXE CON JAVA Y ESTO LO QUIERO PASAR A SERVLET, Y MANDAR
> A UNA BASE DE DATOS OBTENIDO DE UN ARCHIVO XML, PERO CON LA DIFERENCIA
> QUE QUIERO QUE EL SERVLET SEA LLAMADO POR UN JSP PARA EJECUTAR EL EXE,
> ES DECIR PODER MANDAR A LLAMAR EL EXE CON UN BOTON QUE ACTIVE EL
> SERVLET EN EL CUAL ESTA CONTENIDO LA EJECUCION DEL EXE, Y PUES LO DE LA
> BASE DE DATOS NO ES TAN DIFICIL, NO SE MUCHO DE JSPs PERO EN SI NO SE
> COMO ES QUE SE PUEDE COMUNICAR UN JSP Y UN SERVLET, AGRADECERIA MUCHO
> ALGUNA IDEA O AYUDA, FELIZ Aร‘O A TODOS, EMPEZANDO CON EL PROPOSITO DEL
> Aร‘O AQUI ESTA MI PRIMER DUDA, GRACIAS.
Technical Details
Message-ID: <1169078395.265407.236010@v45g2000cwv.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!v45g2000cwv.googlegroups.com!not-for-mail
References: <1167883937.241432.7640@6g2000cwy.googlegroups.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1116f3,539977a41a07298a
X-Google-Attributes: gid1116f3,public
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!v45g2000cwv.googlegroups.com!not-for-mail
From: "Intruder_Inside" <onatevictor@gmail.com>
Newsgroups: es.comp.lenguajes.java
Subject: Re: hola mi problema es con JSPs, ejecucion de un exe y servlets
Date: 17 Jan 2007 15:59:55 -0800
Organization: http://groups.google.com
Lines: 83
Message-ID: <1169078395.265407.236010@v45g2000cwv.googlegroups.com>
References: <1167883937.241432.7640@6g2000cwy.googlegroups.com>
NNTP-Posting-Host: 200.71.33.133
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1169078400 25199 127.0.0.1 (18 Jan 2007 00:00:00 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 18 Jan 2007 00:00:00 +0000 (UTC)
In-Reply-To: <1167883937.241432.7640@6g2000cwy.googlegroups.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: v45g2000cwv.googlegroups.com; posting-host=200.71.33.133;
   posting-account=-WvVYQ0AAABiLSCN-Yk4ygS66eWv4QsC