0

I have following property url.xyz in properties file which will be read in spring applicationcontext.xml file

url.xyz=https://test.com/?name=sample&id=123

I want to further add headers to it for example

'cache-control:no cache'
'content type:text/plain'

Above url returns a password. I want to create a bean in Spring which will invoke url above with headers and return the password

  <bean id=pwd" class="java.lang.String">
        ????
   </bean>

how can this be acheived?

tech_questions
  • 223
  • 3
  • 13
  • 1
    You add headers to a HTTP request, not to an URL . – Arnaud May 18 '18 at 14:27
  • Can you please tell me know can i create a spring bean which connects to the url with urls ? This url returns a password when called – tech_questions May 18 '18 at 14:45
  • You need to create a class that will do that, and then instantiate it as a bean. See https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests for some examples on actually making http requests and handling responses. – Gus May 18 '18 at 15:07

0 Answers0