Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why cant i see request.getHeader() output

800558Apr 28 2009 — edited Apr 29 2009
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,
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 27 2009
Added on Apr 28 2009
3 comments
338 views