liz munroe

Greenhorn
+ Follow
since Mar 01, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by liz munroe

If the included page will be changing (i.e. a table of contents), use jsp:include. This way, it includes the file at the time the jsp file is requested. You can use regular jsp scripting in the included file.
If the included file will not be changing much (i.e. a graphical header), use <%@ include file="foo" %>. It includes the file at the time the servlet is created. You can use regular jsp scripting in the included file here too.
Here's two links for you to read more:
http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-JSP.html#Section8.1
http://www.jspinsider.com/reference/jsp/jspincludes.html
18 years ago
is this the flow of the problem?
1) page1.jsp loads
2) user clicks on something to go to page2.jsp
3) page1.jsp stays in the browser until page2.jsp does all it's stuff and then page2.jsp loads completely.
if so, make page1.jsp like this:
<html>
<head>
<script>
<!--
function showWaitingMessage() {
// IE5 and NN6
if (document.getElementById) {
document.getElementById("waitingpart").style.visibility="visible";
document.getElementById("realpart").style.visibility="hidden";
}
// NN4
else if (document.layers) {
document.layers["waitingpart"].visibility = "visible";
document.layers["realpart"].visibility = "hidden";
}
// IE4
else {
document.all.waitingpart.style.visibility="visible";
document.all.realpart.style.visibility="hidden";
}
}
//-->
</script>
</head>
<body>
<div id="realpart" style="visibility:visible">
Your page1.jsp normal html and/or other jsp stuff goes in here.
and
so does:
<a href="page2.jsp" onClick="showWaitingMessage()">
</div>
<div id="waitingpart" style="visibility:hidden">
Please stand by while the data is gathered etc...
</div>
</body>
</html>
BUT...
if page1.jsp is a form and the action is page2.jsp, change it to:

<form name="myform" action="page2.jsp">
...your form stuff here...
<input type="Button" name="thesubmitbutton" value="Submit" onClick="showWaitingMessage();window.document.myform.submit()">
</form>
or if it's the case that half of page2.jsp begins loading and then stalls while you perform the other stuff, let me know and I can try to help with that case instead. :-)
18 years ago
Make sure that whatever Tomcat is running as (as a service or as system?) has permission to run your exe.
Here is some sample code. I am using unix, so for the variable yourCommand, instead of "/home/liz/test.pl" put in "C:\path\to\your\exe.exe" and uncomment the error and output lines if you need those.
If you need to pass in parameters to your exe, define them and then add them to the fullCommand array. i.e.
String yourCommand = "C:\path\to\your\exe.exe";
String yourParam = whatever;
String[] fullCommand = { yourCommand, yourParam };
You can't use fullCommand = "yourCommand yourParam";
Also, if the path to your exe has spaces in it, you need to put it in quotes. i.e.
String yourCommand = "\"c:/program files/your.exe\"";
I got most of the code from Jason Hunter's Java Servlet Programming book (first edition) in Chapter 13.
good luck!
***************************
<%@ page import="java.io.*" %>
<html>
<head>
<title>Exec example</title>
</head>
<body>
<%
String yourCommand = "/home/liz/test.pl";
String[] fullCommand = { yourCommand };
try {
Process p = Runtime.getRuntime().exec(fullCommand);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
//read the output from the command
//out.println("Here is the standard output of the command:<br>");
//String s = null;
//while ((s = stdInput.readLine()) != null) {
// out.println(s + "<br>");
//}
// read any errors from the attempted command
//out.println("<P>Here is the standard error of the command (if any):<br>");
//while ((s = stdError.readLine()) != null) {
// out.println(s + "<br>");
//}
//int exitVal = p.waitFor();
//out.println("Process exit value = " + exitVal);
} catch (IOException ioe) {
System.err.println("\n\n\nIOException: " + ioe.toString());
}
%>
</body>
</html>
18 years ago
Hi. Change this line:
String cmd = "/usr/bin/perl newfup.cgi";
to
String[] cmd ={"/usr/bin/perl","/fullpath/to/file/newfup.cgi"};
(and /fullpath/to/file is the absolute path from the root directory).
18 years ago