myrizvi
asked on
JSP script giving blank output on HPUX
Hi experts,
The follow code is generating a blank page while running from hp-ux (tomcat installed) :
-------------------------- ---------- --- CODE START -------------------------- ---------- ---------- ---------- -------
<%@ page language="java" import="java.io.*, java.util.*, java.lang.*" %>
<p>Testing Page</p>
<%
StringBuffer sb = new StringBuffer();
try
{
String cmd = "ls";
System.out.println ("Starting the process");
Runtime runTime = Runtime.getRuntime();
Process process = runTime.exec(cmd);
InputStream inputStream = process.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader (inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStream Reader);
String line = null;
while ( (line = bufferedReader.readLine()) != null ){
sb.append(line); sb.append("\n");
}
System.out.println("Output : " + sb.toString());
int exitVal = process.waitFor();
System.out.println ("Process exitValue: " + exitVal );
}catch (Throwable t)
{
t.printStackTrace();
}
%>
-------------------------- ---------- ---------- ------- CODE END -------------------------- ---------- ---------- ----
-------------------------- ---------- ---------- ------- OUTPUT START -------------------------- ---------- --------
Testing Page
-------------------------- ---------- ---------- -------- OUTPUT END -------------------------- ---------- ---------- -
Any help?
Thanks in advance.
The follow code is generating a blank page while running from hp-ux (tomcat installed) :
--------------------------
<%@ page language="java" import="java.io.*, java.util.*, java.lang.*" %>
<p>Testing Page</p>
<%
StringBuffer sb = new StringBuffer();
try
{
String cmd = "ls";
System.out.println ("Starting the process");
Runtime runTime = Runtime.getRuntime();
Process process = runTime.exec(cmd);
InputStream inputStream = process.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader (inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStream
String line = null;
while ( (line = bufferedReader.readLine())
sb.append(line); sb.append("\n");
}
System.out.println("Output
int exitVal = process.waitFor();
System.out.println ("Process exitValue: " + exitVal );
}catch (Throwable t)
{
t.printStackTrace();
}
%>
--------------------------
--------------------------
Testing Page
--------------------------
Any help?
Thanks in advance.
do you have the correct permissions and are you in the correct shell?
ASKER
Hi TimYates,
Yes the output was going to CATALINA.OUT file.
After putting this :
out.println( "Output : " + sb.toString() )
Output is appearing on the webpage without newline, but with this :
out.println( "Output : " + sb.toString().replaceAll( "\\n", "<br>" ) )
Following ERROR appearing :
-------------------------- ---------- ---------- ERROR OUTPUT START -------------------------- ---------- ------
exception
org.apache.jasper.JasperEx ception: Unable to compile class for JSP
An error occured between lines: 4 and 31 in the jsp file: /test1.jsp
Generated servlet error:
/sasgsmapp/sasgsm/mds/sas/ ui/work/lo calhost/sa s5/test1$j sp.java:80 : Method replaceAll(java.lang.Strin g, java.lang.String) not found in class java.lang.String.
out.println( "Output : " + sb.toString().replaceAll(" \n","<br>" ));
^
1 error
-------------------------- ---------- ---------- ---------- --- END -------------------------- ---------- ---------- ---------- -----
Thanks.
Yes the output was going to CATALINA.OUT file.
After putting this :
out.println( "Output : " + sb.toString() )
Output is appearing on the webpage without newline, but with this :
out.println( "Output : " + sb.toString().replaceAll( "\\n", "<br>" ) )
Following ERROR appearing :
--------------------------
exception
org.apache.jasper.JasperEx
An error occured between lines: 4 and 31 in the jsp file: /test1.jsp
Generated servlet error:
/sasgsmapp/sasgsm/mds/sas/
out.println( "Output : " + sb.toString().replaceAll("
^
1 error
--------------------------
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or, upgrading to java 1.4 will get you the "replaceAll" function ;-)
ASKER
YAHOOOOOOOOOOOOOOOOOOOOOOO OOOOOO !!!!!!
Its done man :)
Many many thanks to TimYates.
Its done man :)
Many many thanks to TimYates.
Yay!
Good luck with it!!
Tim
Good luck with it!!
Tim
You don't send anything to the screen...
System.out.println("Output
should probably be:
out.println( "Output : " + sb.toString().replaceAll( "\\n", "<br>" ) );
That *might* work...
You might need to read the inputstream in a seperate thread...
Step 1: Look in catalina.out for either output, or an exception...