I have a wireless IP camera and I want to make my own web page to show its live stream.
The address of the stream is "http://192.168.1.2:8082/index.cgi" (supposed) and it requires User authentication. This means that when we enter the above URL in browser it asks for username and password.
All what I want is that to make a java applet, on loading the java applet, it should authenticate the URL and show the image/stream.
This is the situation, now the basic problem is that
Q: How to do Http authentication in Java applet?
I shall be thankful for every answer.
You can achieve it by making an HttpURLConnection and appending username and password with the URL. As:
Alternatively (instead of appending username/password to url), you can try( not sure if it is allowed in Applet) setting the default authenticator for http requests like this:
You can also use Apache HttpComponents HttpClient which is very easy to use. To know more about how HTTP requests work in Java, see this answer.