I've stumbled over a bug in the mod_jk, which can be described by:
If I send request using HEAD method to a servlet, the servlet allways shows the method as GET. POST method works as expected.
I've made attached servlet to verify the nature of the problem. I'm using the following environment
OS: Linux Redhat 9.0 on intel platform
Tomcat version: 4.1.31
Tomcat component: mod_jk(1.2.8)
JVM: sun java 1.4.2_03
Webserver: Apache 2.0.53
I've not seen this problem mentioned anywhere, but it surely is there. I would appreciate any comment about the matter.
BR. Arnar
Arnar Gestsson, MSc, Electrical Engineering
TrackWell Software
import java.util.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*;
public class RequestType extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse rsp)
throws ServletException, IOException {
rsp.setContentType("text/html");
PrintWriter out = rsp.getWriter();
String requestType = req.getMethod();
rsp.setHeader("Arnar", " was here");
rsp.setHeader("Content-Type", "arnar");
rsp.setHeader("Request-Type", requestType);
out.println("<html>");
out.println("<head><title> Request Type: " + requestType +
" </title></head>");
out.println("<body>");
out.println("<p>This page is the result of a " + requestType +
" request.</p>");
String name = "user-agent";
String value = req.getHeader(name);
if (value == null) {
// The request header was not present
}
// Get all request headers
Enumeration enum = req.getHeaderNames();
for (; enum.hasMoreElements(); ) {
// Get the name of the request header
name = (String)enum.nextElement();
out.println(name);
// Get a value of the request header
value = req.getHeader(name);
// If the request header can appear more than once, get all values
Enumeration valuesEnum = req.getHeaders(name);
for (; valuesEnum.hasMoreElements(); ) {
// Get a value of the request header
value = (String)valuesEnum.nextElement();
out.println(" "+value);
}
}
out.println("</body></html>");
out.close();
}
public void doPost(HttpServletRequest req, HttpServletResponse rsp)
throws ServletException, IOException {
doGet(req,rsp);
}
public void doHead(HttpServletRequest req, HttpServletResponse rsp)
throws ServletException, IOException {
String requestType = req.getMethod();
rsp.setHeader("Arnar", " sent head");
rsp.setHeader("Request-Type", requestType);
}
}
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
