I have a very typical and conceptual problem. I want a precise answer and I request everyone to

provide me the answer to the best of their understanding. The problem seems simple but it's not


Question Summary -

I am trying to set headers from my Servlet and forwarding to the JSP page. On the JSP page I am

trying to get back the header that was set from the servelt. I get a null

I am using WSAD 5.1 for this testing


// FROM servlet

resp.setHeader("name", "america");

// somewhere down the servlet, I forward to jsp

ServletContext context = getServletContext();
RequestDispatcher requestdispatcher=context.getRequestDispatcher("america.jsp");

// this is my jsp

String america = request.getHeader("name");

// I am getting null for this line below

System.out.println("america is ="+america);

Note: I have used all premutations/combinations, by getting dispatcher from request (instead of context), using include

instead of forward etc etc.. nothing worked. The header is not returing any value just null

Please advise with concrete solution

Thanks a lot