Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Follow redirect Link

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Follow redirect Link

    I am building a java program that requires reading a specific web page. What makes it hard is that the
    page I want to read is being redirected to by another page. The following list describes the issue:

    1- Give the program a link that will do some actions and then redirect to another link
    2- Read the new link and its content.

    Issues:1- The original link's response code is 200 not 301
    2- The link that is being directed to is a one session link and cannot be re-accessed

    Example: Assume that there is a link that opens to a page that tries to look up
    a flight between two cities. This page shows a loading image and as soon as it
    collects the results, it directs you to them in a new page that is one session page which
    what I need to read.

    What I did:
    I tried to use HTTPClient but I couldn't really understand how it works. What I need to do is very simple,
    Enter a link that will look for all available flights. This page is a loading page that generates a one session link. I need to be able to read that one session link (read the source file). I know how to read the source file, but I don't know how to access it since I cannot grab that page. I used java.net.URLConnection and java.net.HttpURLConnection to open a connection with the link or the page where looking for flights is happening, but I couldn't figure out how to get to the next page where flights are being displayed since the response code is 200 which means succession. If the response code was 301, my life would be much easier.

    I'm looking forward to hearing any suggestions...
    Last edited by jalalirs; October 9th, 2011 at 11:38 PM.


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Follow redirect Link

    Your probably going to need to provide the URL so people can take a look...
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Follow redirect Link

    Quote Originally Posted by JavaPF View Post
    Your probably going to need to provide the URL so people can take a look...

    This is an example of such URL. It is a link that will look for flight between Jeddah and Riyadh on some date. When you click on it, a loading page will show up and then will direct you to the results' page which I need to read.

    Step 1 - Search for your flights
    Last edited by jalalirs; October 10th, 2011 at 12:11 PM.

Similar Threads

  1. Problem in Servlet redirect
    By surendran610 in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: August 17th, 2011, 12:15 PM
  2. Make my code follow MVC
    By alpvii in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 29th, 2010, 07:48 AM
  3. [SOLVED] Redirect command prompt output to log file.
    By goldest in forum File I/O & Other I/O Streams
    Replies: 9
    Last Post: November 24th, 2010, 05:26 AM
  4. Unable to redirect all the eclipse console logs to buffer
    By skrishnapradeep in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 23rd, 2010, 11:03 PM
  5. Redirect error and output stream using java program
    By leenabora in forum File I/O & Other I/O Streams
    Replies: 5
    Last Post: June 16th, 2009, 04:12 AM