GetURL after redirect

Hello,
I have a small Java code to get an URL content. It works fine but if the URL is redirected then I have the valid content but the getURL methods returns with the original URL. I think it is normal, but how can I get the real URL of the page?
My Java code:
URL u = new URL("http://test/base.php");
HttpURLConnection.setFollowRedirects( true );
HttpURLConnection con = (HttpURLConnection)u.openConnection();
System.out.println("URL: " + con.getURL());And suppose the base.php looks like this:
<?php
   header('Location: http://test/redir.html');
?>What I want is in my Java application to get the http://test/redir.html instead of the http://test/base.php.
Any idea?
Thanks in advance!
Maldiv

sorry if this is a stupid question, but I thought that URLConnection's default behavior is to follow redirects. Have you tried this without the getFollowRedirects method called? (I know, it shouldn't probably do anything, but at least it's something to think about)
edit: I guess that's specifically for html redirects, not php redirects, and I'm not sure if there's a difference, or if the Java APIs regarding this cover redirects in php. Perhaps you could try this with a <meta http-equiv="refresh" content="0;url=queen-of-england.html">sort of redirecting page, to make sure your code isn't messing up on something else. If this works fine, you might have to end up reading the php page to ensure that there isn't a redirection message there, and handling the redirect yourself if such a thing is in the page.

Similar Messages

  • Print statement in JSP page after redirection

    Hi,
    I have written a JSP page and in that i am redirecting it to another page. Now after redirection i am printing a statement on the console. It is getting printed whereas when i am printing the same on the browser i am not able to print that. Please can any one tell me the difference between printing the same on the console and browser.
    My first JSP page(one.jsp)
    <%
         response.sendRedirect("two.jsp");
         out.println("After redirect");
         System.out.println("After out");
    %>
    My second JSP(two.jsp)
    <%
         out.println("In two.jsp");
    %>
    Thanks in advance
    regards
    Prashanth

    The sendRedirect sets a code in the HTTP response being sent to the client (I believe it is a 302 code but I am not sure off hand) and then proceeds to process the rest of the JSP on the server which is why the print statement shows up in the console.
    The out.println writes to the HTTP response output stream. The client gets the response and sees the HTTP Header code telling it to make a new request so it stops processing the response message and sends a new request message which is why the out.println message is not seen in the browser.

  • My getURL code redirects the parent page, help!

    my getURL code redirects my parent page to a weird blank page
    and display "[object]" in the top left corner. I notice my source
    code wipes out and the "[object]" is in there. Does anyone have any
    suggestions?
    Here's the website -->
    http://dev.expertcs.com/elsabet
    Click on the link portfolio, and click on the main picture
    display to see the problem I'm experiencing.
    Here's the code below:

    Thanks for the extra info...
    Could be the 3 or 4 Digit Security Code on the back of your Credit Card...
    http://support.apple.com/kb/TS1646

  • Session not closing after redirecting from BSP View

    Hi All,
    I am trying to redirect to a new application (WD ABAP) from an existing BSP View by using
    CALL METHOD runtime->server->response->redirect( url = lv_url1 ).
    The session still exists in SM04 after redirecting but I want the BSP session be closed.
    Any pointers to how this can be done??
    "navigation" global object is not recognized in the View it seems because I was thinking of using
    navigation->exit (url).
    navigation->response_complete().
    but it gave complie errors.
    Awaiting your suggestions..
    Thanks and Regards
    Avinash

    Please have a look at the BSP application SYSTEM => page => sessionexit.htm

  • GetURL AFTER movie plays

    i'm trying to play a .flv file that is called from within a
    .swf
    i've got that part working using flash by just importing the
    video into scene 1. it plays the video.
    now when the video has finished playing -- and not until then
    -- i then want to do a getURL to splash.htm in order for the viewer
    to be taken to another page on the site where there is a nice
    looping graphic for them to see but only AFTER the video has
    finished playing
    i don't know where to put the getURL. i assume i'm not
    expected to figure out precisely on which frame number the movie is
    going to finish playing and put the getURL there right?
    isn't there a way for it to do the getURL after and only
    after the .flv movie has finished playing, whenever that may be?
    as it is now, it does the getURL before the video has
    finished playing with the frame i've got it on now or if i put the
    getURL in the next scene it just does the getURL before the video
    has had a chance to play through
    is there a way for it to know that the video is playing and
    not launch the getURL until it's done?
    i'm looking for a way to do this using the guided script, i
    don't know code

    How am I playing it? I opened up a New Flash Document in
    Macromedia Flash Professional 8. I did a File > Import Video and
    then specified the .flv file and opted for 'Progressive Download
    for a Web Server' option. It processed that and I had a video on
    the stage, that's it.
    Then File > Export Movie creates a .swf file that
    apparently automatically calls and plays the .flv file. I didn't
    add any code or actions or anything and it plays.
    Does that tell you how I'm playing the video or might I be
    leaving something out?
    I looked up NetStream.onStatus but I don't know code and it's
    pretty Greek to me...what exactly am I supposed to do to get it to
    do a getURL action after the movie has played? I'm not even sure
    where the code would go, like on which frame...within the same
    scene where the video is playing I assume?
    For comparison on ease of use, the swishvideo program I was
    using has a toggle button on the export options that you just click
    and then type in the URL you want launched, so this is pretty far
    removed for me in terms of complexity...

  • Losing beans after redirecting in jsp

    hi , everybody
    I am new in web programming.
    this is my jsp :
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <bean:write name="mess" property="text"/><br>
    your username: <bean:write name="user" property="name"/><br>
    your password: <bean:write name="user" property="password"/><br>
    To add the book to Database click <a href="/pages/BookAdding.jsp">here</a><br>
    To rent the book click <a href="pages/RentBook.jsp">here</a>
    </body>
    </html>
    <as you can see here i have 2 javabeans 1-mess 2-user
    and 2 possibilities for redirection (<a href....>)
    after redirection my beans are null....
    somebody can help me please???
    thanks

    First of all, the taglib declaration should be on the top of you jsp.
    <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <bean:write name="mess" property="text"/><br>
    your username: <bean:write name="user" property="name"/><br>
    your password: <bean:write name="user" property="password"/><br>
    To add the book to Database click <a href="/pages/BookAdding.jsp">here</a><br>
    To rent the book click <a href="pages/RentBook.jsp">here</a>
    </body>
    </html>The beans are lost because they have either a page or a request scope.
    To avoid this, put them in the session scope instead.
    A very good tutorial here http://courses.coreservlets.com/Course-Materials/csajsp2.html
    See The JSP 2.0 Expression Language: Simplifying MVC and Access to Java Code part.
    Hope it helps

  • Time out error after redirection (ADFS-Office 365 SSO)

    Hi everyone,
     I've been having a problem with configuring ADFS and Office 365 SSO. So Everything is setup and signing into office 365 from the internal network works perfectly but when trying to access from the external network I get timed out. A brief overview
    of my setup:
    LAN------>Firewall---------->Firewall------>Internet
                       |
                     DMZ
    LAN network: 192.168.50.0/24
    DC-DNS, RODC-DNS, ADFS1-ADFS2 (NLB), DIRSYNC.
    DMZ: 172.16.50.0/24
    ADFS Proxy1-ADFS Proxy 2 (NLB) (NLB IP: 172.16.50.225)
    Firewall-Firewall: 10.10.10.0/24
    Internal Firewall: Inside: 192.168.50.254/Outside: 10.10.10.2
    External Firewall: Inside: 10.10.10.1/Outside: 172.31.130.83 (working in a class lab with my universities private network)
    Our network engineering department has its own firewall, I was given a Public IP address of 199.50.X.X that port forwards both port 80 and 443 to the outside interface of the external firewall (172.31.130.83)
    The internal firewall allows outgoing and incoming connections from anywhere for troubleshooting the issue. The External Firewall has been configured portforward both port 80 and 443 to the adfs proxy NLB address.
    Other firewall configurations such as NAT and static routes have been configured correctly.
    I've updated the public DNS records, the A record for my ADFS from the public IP address godaddy assigned to my public domain to the public IP given to me (199.50.X.X). I added the adfs server internal IP and name to the adfs proxy host files and DNS resolution
    is working both internal and externally.
    Using a domain-joined computer and user I am able to sign into office 365 with no problems. The problem starts when I try to access from an external device. When entering a domain user email at the office portal, it tries to redirect me to my adfs proxy
    but after a minute or so it fails to load my internal adfs login page and using google chrome I see a timeout error.
    Checked event viewer on both adfs and adfs proxy servers and nothing is showing up, checked my firewalls and everything seems to be working fine, I also confirmed that the faculty's firewall is receiving and forwarding correctly through ports 443 and 80
    (my external firewall also shows the same results).
    Any help would appreciated, been troubleshooting for more than  week and pretty much out of options other than starting over.
    Thank you.
    Moe.

    Hi Moe,
    Regarding specific ADFS query, I suggest you refer to experts from the following forum to get professional support:
    Claims based access platform (CBA), code-named Geneva Forum
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=Geneva
    Thank you for your understanding and support.
    Best Regards,
    Amy
    Please remember to mark the replies as answers if they help and un-mark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • How to have web page open in same browser window after redirect in Flash video placed in Dreamweaver?

    Hello,
    Would be grateful if anyone can help me.
    website: www.Paris-Pet.com
    Currently, a flash video plays on the index page. The following action is placed in the last frame of the video in Flash:
    navigateToURL(new URLRequest("http://www.paris-pet.com/home.html"));
    This is working as intended with one exception: Instead of directing to the home page from the index page when the video is completed, it opens up the home page in a second browser window, leaving the empty browser window of the flash movie. This is not the seamless design I was hoping for, and I've also been told on some computers, blocking pop up windows is preventing them from smoothly transitioning to the rest of the web site.
    I would like the redirect to open the home page in the same browser window as the movie in the index page played.
    Please help. Print designer in over her head.
    JM

    Brilliant, Jon. Thank you so much. For those of you who stumble on this, I did have a tiny bit of trouble when I edited the actionscript; the video didn't play as expected. After trial and error, this is the code that worked both in playing the video and opening up in the same browser window:
    navigateToURL(new URLRequest("http://www.paris-pet.com/home.html"),"_self");
    The difference seems to be this:  ")     before the comma prior to "_self");
    Again, Jon -- thanks!
    Jack

  • Disabled button after redirect

    I have created a page with a region button on it. The button has a redirect to a URL which runs a pl/sql procedure.
    After clicking the button, the procedure runs and I see my original page, but, the button is disabled.
    When I look at the page source, I see that the button has the attribute:
    onClick="javascript: this.disabled=true;"
    How can I keep the button from being disabled?
    Thanks for this wonderful forum.
    Cy

    Thanks for the reply,
    I actually tried that first. The problem is that I need the procedure to download a custom CSV file. It works with a redirect to a url. I could not make it work from a page process. There are several threads and a how-to about downloading a csv file. Nothing helped me get it to work from a page process.
    My whole application revolves around the user selecting some items from a report and clicking a button to get a custom csv built and downloaded. The csv has too many columns to be a report download and the columns may be too wide.
    Thanks again,
    Cy

  • Cannot conect to Job server after redirecting log files

    Platform: Windows
    Software: Data Services 3.0 (Data Integrator 12.0.0)
    Issue: When redirecting the Log files to go to another drive on the windows Server, we are unable to reconnect to the Job Server with Designer.
    We did the following to re-direct the Log files:
    In the DSConfig.txt file on the machine where the jobserver runs, they will find a section similar to the following:
    [AL_JobServer]
    AL_JobServerPath=C:\PROGRA1\BUSINE1\DATAIN~1.7\bin\al_jobserver.exe
    AL_JobServerLoadBalanceDebug=FALSE
    AL_JobServerLoadOSPolling=60
    AL_JobServerSendNotificationTimeout=60
    AL_JobServerLoadRBThreshold=10
    AL_JobServerLoadAlwaysRoundRobin=FALSE
    AL_JobServerAdditionalJobCommandLine=
    ServiceDisplayName=Data Integrator Service
    AL_JobServerName1=WestJS
    AL_JobServerPort1=3500
    AL_JobServerRepoPrefix1=
    AL_JobServerLogDirectory1=
    AL_JobServerBrokerPort1=
    AL_JobServerAdapterManager1=
    AL_JobServerEnableSNMP1=
    AL_JobServerName2=EastJS
    AL_JobServerPort2=3501
    AL_JobServerRepoPrefix2=
    AL_JobServerLogDirectory2=
    AL_JobServerBrokerPort2=
    AL_JobServerAdapterManager2=
    AL_JobServerEnableSNMP2=
    (As with any DSConfig.txt edits, I always tell customers to be very careful, to only follow instructions they receive from customer assurance, and to make backups of the prior file in case they need to revert.)
    Note that there is a u201CWestu201D jobserver defined with the 1 suffix, and an u201CEastu201D jobserver defined with the 2 suffix.  Both jobservers will by default log into %LINK_DIR%\log\ into a directory named after their jobserver name.  If the customer wants to redirect the logs for the u201CWestu201D jobserver to a different path, add the following to this section:
    AL_JobServerLogReDir1=D:\dierrorlogs\Log
    Note the use of the suffix 1 u2013 it means that it will be a part of the settings for the u201CWestu201D jobserver.  The u201CEastu201D jobserver will still log to %LINK_DIR%\log\EastJS while the u201CWestu201D jobserver will log to D:\dierrorlogs\Log.
    All we did was add the one single line AL_JobServerLogReDir1="E:\Program Files\BusinessObjects\dierrorlogs\Log"
    Can anyone give us some sort of suggestion or idea as to why we lost our connection to our Job Server with this change?  We DID restart the service.
    Thanks!  Ken

    I am not sure if this Parameter actually works ? I have to check that
    can you see the JobServer process in the task manager ? check the windows event log for any errors for the JobServe
    since you modified the path, I don't think it will be generating any log file for Job server
    what's the status for the job server in Desginer and Management console ?

  • Code after redirect (or forward)

    Suppose that I redirect from a servlet to a jsp and I want that some code of the servlet is executed after the jsp presentation, how can I do this?
    response.sendRedirect("/jsp/onejsp.jsp");
    code_to_execute_after_jsp_presentation();
    The problem is that the jsp is called after all the code of the servlet is executed.
    There is a solution to this problem?
    Thanks
    Luciano

    Hi,
    I saw several of your messages that talk about "sendRedirect". I have the same problem. I have 2 JSP pages, but they are in two different location (JVM). I would like to send some session Attributes (using session.setAttribute from source JSP) to the target JSP. Therefore it can be read as session attribute also it will not show user what is the Parameter and details (if you send Parameter using "?CustomerID=<%= CustomerID %>" then user can see the info by viewing the source).
    If you know the answer already, can you let me know?

  • Preserving facesmessages after redirect

    Hi ,
    I need to render a facesmessages after the redirection. And i also have to end the conversation before redirect. In pages.xml I have the following code:
    <navigation from-action="#{abc.edit}">
    <end-conversation before-redirect="true" />
    <redirect view-id="/abcList.xhtml">
         <message>successfully edited.</message>
    </redirect>
    </navigation>
    I need to display this message after the control is redirected to abc.xhtml. What i need to do here

    The messages are stored in the request scope. So, the clearing is expected.
    Look at http://jsffaq.com/Wiki.jsp?page=HowToShowFacesMessageOnTheNextPage
    for some clues how to solve the problem.
    Sergey : http://jsfTutorials.net

  • Does control comes back to servlet after redirecting to a jsp page.

    Hi
    I have a query on request dispatcher.
    I have redirected control to a jsp page in my java class as below.
    HttpServletRequest request=null;
         HttpServletResponse response=null;
         RequestDispatcher requestDispatcher = request.getRequestDispatcher("a.jsp");
         try {
              requestDispatcher.forward(request,response);
         } catch (ServletException e) {
              System.out.println("success");
              e.printStackTrace();
         } catch (IOException e) {
              System.out.println("success 1");
              e.printStackTrace();
         finally
              System.out.println("success 2");
         System.out.println("success 3");
         Jsp page is successfully diaplayed in browser.
    but when i see my console window in eclopse IDE...
    I does not diaply Success 2 / Success 3....
    Please help me..
    thanks

    This is an eclipse/server question... not really a java question.
    I have NO IDEA how eclipse interplays with you're (unspecified) server.
    I can tell you that typically the standard output and error streams of the J2EE server are redirected by the server startup script to a file in the deployed applications root directory... So have a look around.
    Edited by: corlettk on 16/05/2008 04:49 - Oops.

  • Confirm OK/Cancel: could not stop processing after redirect

    I am have a problem doing a JavaScript confirmation which in a cfinclude file in the process page.
    When the display page send content to the process page, and process page first do some validation which is included in a cfinclude file. The issue is user need to choose from a confirmation message box, choose OK to continue processing, Cancel to send user to previous display page. Every thing seems working, except when user choose Cancel and is sent to the previous page, the execution on the process page continues anyway, behind scene though. Without server process validation you may not realize it. but the truth is it does not stop when user choose Cancel.
    So I need your insights how to handle the situation: give user choice to choose but when user select Cancel, stop the execution of the code after cfinclude.
    Is there anyway to do the message box without JavaScript? If only it could be done in Coldfusion, then the problem solve, by setting a coldfusion variable to stop the execution.
    Please help!
    Thanks
    Jush

    Keep in mind that cf runs on the server, js runs on the client, and the two don't know what the other is doing.  You have a couple of choices.
    1.  Put the validation on the initial page so that selecting cancel keeps them on that page.
    2. Have a page that does validation and nothing else.  Have the rest of the code on another page.  Use js to send the user to the proper page depending on what they select with the confirm dialogue.

  • How do I reset Business Catalyst log-on after redirecting website to Google Sites?

    I am trying to log into my Business Catalyst account after moving my website to google sites - the BC login tries to go to the new website instead of logging into a business Catalyst dashboard.
    All I want to do is to make sure the Business Catalyst account is closed and files are deleted - but can't get to it.

    Is the user logging out or is the internet disconnecting after 15 minutes?
    If the user is logging out go to System Preferences > Security and there is an option to log-out after a specified time period inactive, uncheck that box.

Maybe you are looking for

  • Bdc for info records

    Hi all , i have developed a bdc progoram for inforecords..               while uploading the data if there are two conditions or more for same vendor and material i am getting the correct one but netprice for first condition comes correctly . if the

  • Finding columns using all_tab_columns

    I am using oracle 11g and i am having trouble finding a column name using all_tab_coulmns .Basically i dont know the exact name of the column and i used wild card in the where clause but i seems line wild card doesnt work.Could this be because of the

  • Regarding group condition

    hi friends 1.wht is header condition and group condition? 2. what r the condution types for header and group conditions? 3. give me some examples for useful of header condition and group conditon? plz reply me thanks in advance

  • Create a file and store it in the database using UTL_FILE package

    Hello. I'm using UTL_FILE package to store data from a table into an excel file but I don't know how to store this file in a table with a BLOB field the database at the same time. I want do do this because I will use it in a Oracle Portal. Anybody ha

  • TS1424 taking a long time to download

    Download time seems to be taking forever. Any suggestions?