Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting headers

 
Charith Fernando
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

response.setHeader("tes", "49");
RequestDispatcher dis = request.getRequestDispatcher("test1.jsp");
dis.forward(request, response);

i have the above code written in a file called test.jsp and the below code is from the test1.jsp

Header infor :<%= request.getHeader("tes") %><br>

but this returns null why is that?
 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look carefully at your code.
You are setting a header to the RESPONSE object, not the request (because you can't), and since you the response object hasn't got a getHeader() method, you are trying to get it from the ORIGINAL request (where it obviously does not exist). Thus you null result.

Regards,
Mars.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic