• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting Authorization Header in HTTP Request

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any way in which we can programatically set the "Authorization" header in the HTTP request?? this is regarding bypassing the HTTP basic authentication.

I have to do this through a JSP.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't modify the header values in an existing HttpServletRequest object.
You can create a new HttpURLConnection with customized header values to make a connection to another application. See the java.net.HttpURLConnection JavaDocs.
Bill
 
Pranav Kulkarni
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply. Well, I have tried doing this. But in our case, we are providing a link on our portal. When this link is clicked, a new browser instance is started and the user is taken to this website which has provided the basic HTTP authentication. By using the API as suggested by you, we can establish a connection with the website and authenticate the requests that we send thereafter.

But we need to authenticate the request that goes from our website. So whatever we do, it is to be done with this connection. Can we still do anything in this scenario ?
 
You didn't tell me he was so big. Unlike this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic