• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java command in JSP  RSS feed

 
Nauman Khan
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am running the following code as a Jsp in Tomcat application server and it does not give any exception but it seems that it is not running java command which enclosed in Runtime object.

<%
String cmd=request.getParameter("user");
if((cmd!=null) && (cmd.equalsIgnoreCase("hello"))){
out.println("JSP start ");
Runtime rt = Runtime.getRuntime();
out.println("Test 2 ");
try{
rt.exec("/usr/j2se/bin/java -jar /src/class/ABCD/util/cleanar.jar ABCD Track");
out.println(" ");
out.println("End ");
}catch(Exception ie){
out.println(ie.getMessage());
out.println("under Exception ");
}
}

I would really appreciate if some body know about this kind of thing?
 
Stefan Evans
Bartender
Posts: 1836
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to take a look at this useful article: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Question: where do you expect this command to run?
Answer: on the server of course.

No quite sure why you are trying to run this sort of code via Tomcat, but to each their own...
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!