Discussions

Web tier: servlets, JSP, Web frameworks: Edit HTTP header vairable and redirect

  1. Edit HTTP header vairable and redirect (4 messages)

    Hi All,
    Thanks for reading this post.

    I would like to edit the http header varible in one servlet and redirect/forward to another servlet, in this second servlet I should be able to retrive the header variable using request.getHeader("MY_HEADER_INFO"). The following are the options I tried out
     response.setHeader("MY_USER","GAUTHAM");
     request.getRequestDispatcher("manager/index.jsp").forward(request,response)

     response.setHeader("MY_USER","GAUTHAM");
     response.sendRedirect("manager/index.jsp");

    Please share any thoughts in this regard.

    Thanks
    Gautham
  2. Use the first option (forward). Also you can use a filter instead of the first servlet.

    Marina
    http://www.servletsuite.com
  3. Thanks for the reply Marina,
    The second servlet is actually runing on different context, hence I can't use dispatcher forward.I am sorry I didn't specify this earlier.
    Regards,
    Gautham
    www.satyam.com
  4. Do you have a web server?[ Go to top ]

    Browser has no obligations to return the header to context 2 you set in response object of context 1.

    If you do not have a limitation of using request header I suggest you to go for a cookie based implementation.

    Other wise you have to be smart enough of handling the request header in Apache/Iplanet in case you have.
    If you need help on how to manipulate header in Apache I will be able to help you out. Other webservers are beyond my reach.
  5. dasexpress@hotmail.com[ Go to top ]

    reach me at dasexpress@hotmail.com