Results 1 to 8 of 8
  1. #1
    ujjwal is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default Fetch Source Code

    Hi to all,
    I'm fetching the source code of the Web Page by using HttpURLConnection. But in some Sites , the exact Source code that i want is not Fetched instead it redirects to some other Web Pages. Is there anyBody having idea how I have to fetch the Source code of Redirected WebPages.


    Thanks in Advace
    Ujjwal Khajuria

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    6

    Default

    HttpURLConnection should follow redirects by default. If you do not want this to be the case, set setFollowRedirects to false.

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default

    You can also go old school low level and just open sockets to the server in question. Thats a lot more work of course, but probably twice if not three times as awesome.

  4. #4
    codesmuggler is offline Member
    Join Date
    Feb 2011
    Posts
    30
    Rep Power
    0

    Default

    Quote Originally Posted by quad64bit View Post
    You can also go old school low level and just open sockets to the server in question. Thats a lot more work of course, but probably twice if not three times as awesome.
    Haha. I don't think he knows HTTP protocol in a level that allow him to fetch this website, it's too complicated for a beginner. Maybe use BSD sockets in C instead? Will be more funny ;)

    ujjwal:
    What is fetched instead of the thing you want?
    Last edited by codesmuggler; 02-07-2011 at 08:46 PM.

  5. #5
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default

    I just dial into the website with my phone and scream binary tones into the receiver and handwrite the response... in octal :P

  6. #6
    ujjwal is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default

    It doesn't Fetch the Source Code of the URL That I inserted. instead It fetch the Source code of URL that is Redirected by the previous URL

  7. #7
    ujjwal is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by doWhile View Post
    HttpURLConnection should follow redirects by default. If you do not want this to be the case, set setFollowRedirects to false.
    I already used this but it doesn't give the Output that i want...Even it gives the Source code of Redirected Webpage

  8. #8
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    6

    Default

    Like I said, thats because of the level of the network stack you are on. Java's URL connections are automatically following the redirect. The thing is, if you are getting a HTTP 302 response from the server, then the page itself probably doesn't have any content. I would be curious exactly what message you are getting from the server in response to the initial query.

Similar Threads

  1. source code
    By patel_op in forum Networking
    Replies: 0
    Last Post: 11-18-2010, 08:59 AM
  2. Help me source code
    By choqi Amt in forum NetBeans
    Replies: 2
    Last Post: 07-18-2010, 09:57 AM
  3. Replies: 1
    Last Post: 11-28-2008, 06:27 PM
  4. How to fetch an arralist element (i need the code)
    By raj reddy in forum JavaServer Pages (JSP) and JSTL
    Replies: 7
    Last Post: 04-21-2008, 03:28 AM
  5. Need a source code
    By vissu007 in forum New To Java
    Replies: 1
    Last Post: 07-05-2007, 07:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •