How to pass any value as a HttpHeader from one JSP to another

Hi All,

I am facing one problem regarding passing my one value as HttpHeader[Note: not as a hidden field or parameter] from one JSP page to another. Can anyone has any idea , how can I do so using JS or JSP or anything.

Thanks!
Sookie

Replies

  • Deepika Bansal
    Deepika Bansal
    Hey sookie. What problem are you exactly facing.?
  • sookie
    sookie
    Deepika Bansal
    Hey sookie. What problem are you exactly facing.?
    Hey problem that I am facing is the value that I am adding to header is getting lost in my next page. I need to read that value but i couldn't find it. I have a First.jsp page in which I am adding response like following
    <%=
        response.addHeader("hello", "Hello");
    %>
    
    Now I want to go to my Second.jsp and want to get that value in Second.jsp page header. If I do redirect, this value gets lost. Any idea where I am going wrong in my approach ?

    Thanks,
    Sookie
  • Deepika Bansal
    Deepika Bansal
    Sookie you can use the concept of parameters. In one of my projects I used that and it worked fine for me. You can try it.

    In first page you use the following code:
    
          
    
    
    Here value of the parameter msg will be set as Hello.

    And in the second page, use the following in between the head tags:
    
    String msg=request.getParameter("msg");
    
    
    You'll get your message in the msg variable.


    Another way is that you can attach the values in the html header using '&' sign similar to what as we send values using the 'get' method while submitting the form.

    In your above query, you've mentioned that you don't want to use the concept of parameters. Any particular reason for that because I find it a very convenient way.😀
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    You can also use:
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("your url");
    request.addParameter("parameter", "value");
    dispatcher.include(request, response);

You are reading an archived discussion.

Related Posts

I'm sure you've read our coverage of newly launched 'Thunderbolt' high-speed data transfer technology. The technology has been jointly developed by electronic giants Apple & Intel. I'd like to welcome...
I'm really impressed by the Thunderbolt technology developed by Apple and Intel. It's the latest CS/IT/Electronics Seminar Topic which you can use for your presentation. We've a separate discussion thread...
This would be a typical news item but I'd like to discuss this from a CS engineering perspective. The biggest challenge in front of Google is that they should filter...
Samsung, the leader in display technology is now working on a new technology that will make OLED and CLD look like a thing of past. The biggest disadvantage OLED had,...
I feel sad to see the lack of awareness and willingness among engineers about entrepreneurship and starting new companies on their own. I thought of collecting information about the lesser...