• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting Authorization Header in HTTP Request

 
Pranav Kulkarni
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • 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
  • 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 ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!