Running Apache 1.3.23 and Tomcat 4.10 Stable on Linux. Attempting to open
a stream from a java class to port 80 referencing a servlet in Tomcat. We
can run the code on port 8080 hitting Tomcat directly but when trying to
use port 80 with AJP 1.3 Connector, when attempting to get the inputstream
in the servlet, we receive a null pointer exception. The Apache logs show
a content length is valid but when we print out in the servlet, the content
length = 0.
Here is the the output from the java class that sends:
outStream = new DataOutputStream(socket.getOutputStream());
outStream.writeBytes(config.getHTTPRequestType() + " " +
config.getHTTPServletName() + " " + config.getHTTPVer() + "\r\n"
outStream.writeBytes("Request-URI: " + config.getHTTPServletName()
+ "\r\n"
outStream.writeBytes("Content-Type: " + config.getHTTPContentType
() + "\r\n"
outStream.writeBytes("Host:" + config.getHTTPHost() + ":" +
config.getHTTPPort() + "\r\n"
outStream.writeBytes("Accept:" + config.getHTTPAcceptTypes()
+ "\r\n"
outStream.writeBytes("\r\n"
outStream.writeBytes(msgStr + "\r\n"
outStream.writeBytes("\r\n"
outStream.flush();
Here is the servlet code:
try {
System.out.println("Content Length: " + req.getContentLength());
BufferedReader br = new BufferedReader(new InputStreamReader
(request.getInputStream()));
//br = req.getReader();
out.println("$$$$$$$$$$$br = " + br);
String x = "";
String line = "";
while ((line = br.readLine()).length() > 1) {
x = x + line;
}
out.println(": Request = " + x);
br.close();
} catch (Exception ex) {
out.println(ex);
}
Thanks - JAS
a stream from a java class to port 80 referencing a servlet in Tomcat. We
can run the code on port 8080 hitting Tomcat directly but when trying to
use port 80 with AJP 1.3 Connector, when attempting to get the inputstream
in the servlet, we receive a null pointer exception. The Apache logs show
a content length is valid but when we print out in the servlet, the content
length = 0.
Here is the the output from the java class that sends:
outStream = new DataOutputStream(socket.getOutputStream());
outStream.writeBytes(config.getHTTPRequestType() + " " +
config.getHTTPServletName() + " " + config.getHTTPVer() + "\r\n"
outStream.writeBytes("Request-URI: " + config.getHTTPServletName()
+ "\r\n"
outStream.writeBytes("Content-Type: " + config.getHTTPContentType
() + "\r\n"
outStream.writeBytes("Host:" + config.getHTTPHost() + ":" +
config.getHTTPPort() + "\r\n"
outStream.writeBytes("Accept:" + config.getHTTPAcceptTypes()
+ "\r\n"
outStream.writeBytes("\r\n"
outStream.writeBytes(msgStr + "\r\n"
outStream.writeBytes("\r\n"
outStream.flush();
Here is the servlet code:
try {
System.out.println("Content Length: " + req.getContentLength());
BufferedReader br = new BufferedReader(new InputStreamReader
(request.getInputStream()));
//br = req.getReader();
out.println("$$$$$$$$$$$br = " + br);
String x = "";
String line = "";
while ((line = br.readLine()).length() > 1) {
x = x + line;
}
out.println(": Request = " + x);
br.close();
} catch (Exception ex) {
out.println(ex);
}
Thanks - JAS