Hello, I was just playing around with the request headers in my servlet. Finally at a point where i cannot explain this behavior.
In my servlet Test1.java i have :
protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
response.setHeader("Testing", "5");
RequestDispatcher reqD = req.getRequestDispatcher("/Test2");
reqD.forward(req,response);
}
And my Test2.java looks like :
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("hello");
System.out.println("The headers are.." + request.getIntHeader("Testing"));
}
When i run this code from servlet Test1, which forwards to Test2, i see the final output as :
hello
The headers are..-1
Am not able to udnerstand why am i not able to retrieve the Testing header set in Test1 ??
Any advise.
Thanks,