Results 1 to 6 of 6
- 09-27-2011, 12:33 AM #1
Member
- Join Date
- Aug 2011
- Posts
- 11
- Rep Power
- 0
Read content from URL with an http response code=204
I am trying to read from a website, and the server returns a response code of 204, which is supposed to mean there is no content, despite that the site has content. What is going on? And is there any way to access the html of a site with a 204 response code, to ignore the response code, or at least to get around it in some way?
Last edited by jmu2101; 09-27-2011 at 12:40 AM.
- 09-27-2011, 01:26 AM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Re: Read content from URL with an http response code=204
How do you know the site has content? Without more information - code, the site you are accessing, etc...it is difficult to troubleshoot.
- 09-27-2011, 02:02 AM #3
Member
- Join Date
- Aug 2011
- Posts
- 11
- Rep Power
- 0
Re: Read content from URL with an http response code=204
I know there's content because if i go on the web manually and view source on my browser, i can see the html.
- 09-27-2011, 02:04 AM #4
Member
- Join Date
- Aug 2011
- Posts
- 11
- Rep Power
- 0
Re: Read content from URL with an http response code=204
URL hef=new URL(my website);
BufferedReader kj=null;
int kjkj=((HttpURLConnection)hef.openConnection()).get ResponseCode();
System.out.println(kjkj);
String j=((HttpURLConnection)hef.openConnection()).getRes ponseMessage();
System.out.println(j);
URLConnection g=hef.openConnection();
g.connect();
try{
kj=new BufferedReader(new InputStreamReader(g.getInputStream()));
while(kj.readLine()!=null)
{
String y=kj.readLine();
System.out.println(y);
}
}
finally
{
if(kj!=null)
{
kj.close();
}
}
}
}
- 09-27-2011, 05:38 AM #5
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,619
- Rep Power
- 5
Re: Read content from URL with an http response code=204
Some sites (again you do not mention which site you wish to access, so no one can reproduce your problem to troubleshoot) require appropriate headers to be sent. Try setting certain headers, for example the User agent header corresponding to your browser (google these keywords for more information on how to do this - lots of code snippets out there)
- 09-27-2011, 07:02 PM #6
Member
- Join Date
- Aug 2011
- Posts
- 11
- Rep Power
- 0
Similar Threads
-
Server returned HTTP response code: 500.. i need help
By hardc0d3r in forum Java ServletReplies: 9Last Post: 03-12-2012, 08:08 PM -
Server returned HTTP response code: 500
By fuliangQ in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 04-09-2009, 03:55 AM -
HTTP response not read
By SD_Be in forum NetworkingReplies: 1Last Post: 03-10-2009, 04:36 PM -
java.io.Exception: Server returned HTTP response code: 403
By navishkumarb in forum Advanced JavaReplies: 1Last Post: 01-05-2008, 01:33 PM -
Server returned HTTP response code: 500
By Heather in forum Java ServletReplies: 1Last Post: 07-09-2007, 04:32 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks