Skip to main content
added 84 characters in body
Source Link
Mordechai
  • 16.5k
  • 2
  • 51
  • 89

Instead of using URLConnection in java, if you use HttpURLConnection you should beable to access the requested web page from java. Try the following code:

 HttpURLConnection httpcon = (HttpURLConnection) url.openConnection(); httpcon.addRequestProperty("User-Agent", "Mozilla/4.76"); 

Normal java using urlConnection wont be accepted to access the internet. To access the browser it will need to perform a search without theexception HTTP response code : 403 for URL


EDIT (@Mordechai): No need to do the casting, just add the user agent.

Instead of using URLConnection in java, if you use HttpURLConnection you should beable to access the requested web page from java. Try the following code:

 HttpURLConnection httpcon = (HttpURLConnection) url.openConnection(); httpcon.addRequestProperty("User-Agent", "Mozilla/4.76"); 

Normal java using urlConnection wont be accepted to access the internet. To access the browser it will need to perform a search without theexception HTTP response code : 403 for URL

Instead of using URLConnection in java, if you use HttpURLConnection you should beable to access the requested web page from java. Try the following code:

 HttpURLConnection httpcon = (HttpURLConnection) url.openConnection(); httpcon.addRequestProperty("User-Agent", "Mozilla/4.76"); 

Normal java using urlConnection wont be accepted to access the internet. To access the browser it will need to perform a search without theexception HTTP response code : 403 for URL


EDIT (@Mordechai): No need to do the casting, just add the user agent.

Instead of using URLConnectionURLConnection in java, if you use HttpURLConnection we can ableHttpURLConnection you should beable to access the requested web page from java. Try the following code:

HttpURLConnection httpcon = (HttpURLConnection) url.openConnection(); httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");

 HttpURLConnection httpcon = (HttpURLConnection) url.openConnection(); httpcon.addRequestProperty("User-Agent", "Mozilla/4.76"); 

Normal java using urlConnectionurlConnection wont acceptbe accepted to access the internet. IfTo access the browser it will allowneed to perform a search without this exception "HTTP response codetheexception : 403 for URL"HTTP response code : 403 for URL

Instead of using URLConnection in java, if you use HttpURLConnection we can able to access the requested web page from java. Try the following code

HttpURLConnection httpcon = (HttpURLConnection) url.openConnection(); httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");

Normal java using urlConnection wont accept to access the internet. If access the browser it will allow to perform a search without this exception "HTTP response code : 403 for URL"

Instead of using URLConnection in java, if you use HttpURLConnection you should beable to access the requested web page from java. Try the following code:

 HttpURLConnection httpcon = (HttpURLConnection) url.openConnection(); httpcon.addRequestProperty("User-Agent", "Mozilla/4.76"); 

Normal java using urlConnection wont be accepted to access the internet. To access the browser it will need to perform a search without theexception HTTP response code : 403 for URL

added 181 characters in body
Source Link
Saratha
  • 323
  • 3
  • 4

Instead of using URLConnection in java, if you use HttpURLConnection we can able to access the requested web page from java. Try the following code

HttpURLConnection httpcon = (HttpURLConnection) url.openConnection(); httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");

Normal java using urlConnection wont accept to access the internet. If access the browser it will allow to perform a search without this exception "HTTP response code : 403 for URL"

Instead of using URLConnection in java, if you use HttpURLConnection we can able to access the requested web page from java. Try the following code

HttpURLConnection httpcon = (HttpURLConnection) url.openConnection(); httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");

Instead of using URLConnection in java, if you use HttpURLConnection we can able to access the requested web page from java. Try the following code

HttpURLConnection httpcon = (HttpURLConnection) url.openConnection(); httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");

Normal java using urlConnection wont accept to access the internet. If access the browser it will allow to perform a search without this exception "HTTP response code : 403 for URL"

Source Link
Saratha
  • 323
  • 3
  • 4
Loading