aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes set header and getheader Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "set header and getheader" Watch "set header and getheader" New topic
Author

set header and getheader

Harish Yerneni
Ranch Hand

Joined: Sep 15, 2004
Posts: 94
I am trying to print the value of a header and getting a null value as the output. Any ideas?

code:

resp.setHeader("foo","baris");
String hvalue = req.getHeader("foo");
out.println("<br>foo value is"+ hvalue);

output:

foo value isnull


SCJP 1.4 | SCWCD 1.4 | SCJD (WIP)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14672
    
  11

Are you doing this in the same servlet ??


[My Blog]
All roads lead to JavaRanch
Harish Yerneni
Ranch Hand

Joined: Sep 15, 2004
Posts: 94
yes
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14672
    
  11

You are setting the header to the response. Ok.
You are reading the request header. Ok.
But the request header and the response header are different.
Harish Yerneni
Ranch Hand

Joined: Sep 15, 2004
Posts: 94
Thanks Satou.

I got it.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: set header and getheader
 
Similar Threads
Use of .setHeader() and .addHeader() methods
Display of hashmap values using jstl
Question about servlet filters
Stringbuffer remains unchanged in a method
Passing variable into methods