当前位置: 代码迷 >> Java Web开发 >> jsp中servlet的runtime有关问题
  详细解决方案

jsp中servlet的runtime有关问题

热度:62   发布时间:2016-04-17 15:15:07.0
jsp中servlet的runtime问题
servlet中能用Runtime吗
问题补充:如果能.  
package   test;  
import   java.io.IOException;  
import   java.io.PrintWriter;  
import   javax.servlet.ServletException;  
import   javax.servlet.http.HttpServlet;  
import   javax.servlet.http.HttpServletRequest;  
import   javax.servlet.http.HttpServletResponse;  
public   class   Test   extends   HttpServlet   {  
protected   void   doGet(HttpServletRequest   request,   HttpServletResponse   response)  
throws   ServletException,   IOException   {  
int   i=0;  
Runtime   r   =   Runtime.getRuntime();  
String   str= "start   C:\\WINDOWS\\system32\\notepad.exe ";  
try  
{  
while(i!=3)  
{  
r.exec( "cmd   /c   "+str);  
i++;  
}  
}  
catch(IOException   e){}  
PrintWriter   out=response.getWriter();  
i=0;  
while(i!=3)  
{  
out.println( " <html> <body> <h1> This   is   a   servlet   test. </h1> </body> </html> ");  
i++;  
}  
out.flush();  
}  
}  

上面的那段代码为什么没有打开记事本???

------解决方案--------------------
@_@,new 出来调用就行了,
  相关解决方案