File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes setHeader() and addHeader() practical example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "setHeader() and addHeader() practical example" Watch "setHeader() and addHeader() practical example" New topic

setHeader() and addHeader() practical example

Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1341


I am looking for a pratical example of using setHeader() and addHeader() which can clearly mention the difference between these two.
Please provide me such example.

Thanks in advance

Oracle certified Java 8 Programmer I (1Z0-808), Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist
Ankit Garg

Joined: Aug 03, 2008
Posts: 9453

setHeader sets a named response header and replaces any existing headers with that name. addHeader on the other hand doesn't replace any existing headers with the same name. You can inspect response headers in Firefox using Web Developer Toolbar and using ieHttpHeaders for Internet Explorer...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
I agree. Here's the link:
subject: setHeader() and addHeader() practical example
It's not a secret anymore!