aspose file tools*
The moose likes JSP and the fly likes headers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "headers" Watch "headers" New topic
Author

headers

Ken Sampson
Ranch Hand

Joined: Sep 26, 2007
Posts: 45
Could anybody please help me to understand the use of the following methods.

response.addheader(...)
response.setHeader(...)

Can I use the above methods in setting any custom header esp.

response.setHeader("foo", "bar");


Ken Sampson
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

A good place to start is the API

See if this helps.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Originally posted by Ken Sampson:


Can I use the above methods in setting any custom header esp.

response.setHeader("foo", "bar");


First, you can through the API in the link what Ben had provided.

Next, you have misunderstood the "attributes" vs "headers". You can definitely set your own (user defined) attributes, but not the user-defined headers.

Because the "headers" are some predefined attributes which are standardized and understood/interpreted by the browser (client) as the way it is supposed to be. Even if you gonna add your own header, there would be no purpose/use of it as the browser may not understand what it means.
[ May 21, 2008: Message edited by: Raghavan Muthu ]

Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Raghavan Muthu:

Next, you have misunderstood the "attributes" vs "headers". You can definitely set your own (user defined) attributes, but not the user-defined headers.


I'm not sure how you came to this conclusion.
I don't see enough information in Ken's post indicate a confusion between headers and attributes.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Originally posted by Ben Souther:


I'm not sure how you came to this conclusion.
I don't see enough information in Ken's post indicate a confusion between headers and attributes.


Ben, it was based on the below lines of OP.


Can I use the above methods in setting any custom header esp.

response.setHeader("foo", "bar");
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: headers
 
Similar Threads
meaning of response.setHeader
logout problem
How to control cached pages?
Specify the filename of a dynamically generated image?
Struts 2 - logout - prevent back button