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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
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: 14687
    
  16

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: 14687
    
  16

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://aspose.com/file-tools
 
subject: set header and getheader
 
Similar Threads
Stringbuffer remains unchanged in a method
Passing variable into methods
Question about servlet filters
Display of hashmap values using jstl
Use of .setHeader() and .addHeader() methods