Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Add Header to HTTPServletRequest

843841Oct 9 2007 — edited Oct 9 2007
Hi,

I need to write a test class that sends an HTTP request to a servlet, this request needs a custom header adding to it, can this be done in java?

I haven't been able to find a way of doing this, HttpServletRequest has no addHeader() method and I've been looking at URL and HttpURLConnection class has no method to add a header (that I can tell).

Does anyone know if:

1. is it possible to add your own headers to http requests in java?
and
2. if so, what objects do I need to use?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 6 2007
Added on Oct 9 2007
3 comments
8,740 views