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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Executing notepad in jsp (WIndows 2000)

843835Nov 22 2002 — edited Nov 26 2002
Hey,

I've been playing around with the Runtime API and have run into problem. I want to eventually run a C program through a JSP page, but I can't even get notepad to open successfully. Below is the entire test code that is supposed to open notepad. When I open this JSP page in Windows 2000, nothing happens. The GUI for notepad is never opened. However, I checked the task manager and there is an instance of notepad there, and when I try to end the process it gives me an error saying that access is denied. I wrote a simple java program with similar code, and I am able to successfully open notepad through it. I can't see what I'm doing wrong here. Anyone else have this problem on Windows 2000? Thanks.

<%@ page import="java.io.*" %>
<%
Runtime r = Runtime.getRuntime();
try {
Process p = r.exec("notepad");
} catch (Exception e) {
System.out.println("Error");
}
%>
<html>
...html code...
</html>

Jason



Comments

843835
I've finally determined the cause of all my troubles. It turns out that if Tomcat is running as a service on Windows 2000, it can't access the console and as a result it can't call external programs. I turned off the service temporarily and started up the stand-alone Tomcat application and my JSP pages work without a hitch. Unfortunately, I think they'll want to keep Tomcat as a service, so I haven't completely solved all of my problems. So does anyone know of a way to execute external programs using Runtime.exec() while running Tomcat as a service? Thanks.

Jason
843835
the notepad called by your jsp is the NOTEPAD program under the server part,

so ,under client part , there will be no response, because the logic process of the jsp is disposed under server part.

BUT
how to call a native function of client part under Browser/Server structure ?
i don't know, for example: in an web page (jsp / servlet / applet) to call the
"Outlook Express\\msimn.exe" , which is useful in many B/S applications.
This puzzled me a lot.

Hope some one can give an answer.
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 24 2002
Added on Nov 22 2002
2 comments
83 views