<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: [resolved] getting destination url in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275666#M51971</link>
    <description>Hi Shong, 
&lt;BR /&gt;Thank you for helping me out, managed to get it working! Only for one url so far... Now I'm trying to get it to work with an input stream (rows come from tExtractXMLField) how should I make it work for all rows? Should I be using tJavaRow instead of tJava? 
&lt;BR /&gt;My code now is: 
&lt;BR /&gt; 
&lt;PRE&gt;String url = row15.url;&lt;BR /&gt;java.net.HttpURLConnection con = (java.net.HttpURLConnection) new java.net.URL(url).openConnection();&lt;BR /&gt;con.setInstanceFollowRedirects(false);&lt;BR /&gt;con.connect();&lt;BR /&gt;String realURL = con.getHeaderField("Location");&lt;BR /&gt;System.out.println(realURL);&lt;/PRE&gt; 
&lt;BR /&gt;The part not yet working is&amp;nbsp; 
&lt;FONT face="consolas, monaco, 'bitstream vera sans mono', 'courier new', courier, monospace"&gt;String url = row15.url;&lt;/FONT&gt;&amp;nbsp; if I'd replace row15.url with " 
&lt;A href="http://myurl.com" rel="nofollow noopener noreferrer"&gt;http://myurl.com&lt;/A&gt;"&amp;nbsp;then the code is working for that url. 
&lt;BR /&gt;Thanks, 
&lt;BR /&gt;Henry</description>
    <pubDate>Thu, 07 May 2015 11:37:51 GMT</pubDate>
    <dc:creator>hvanderborg</dc:creator>
    <dc:date>2015-05-07T11:37:51Z</dc:date>
    <item>
      <title>[resolved] getting destination url</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275664#M51969</link>
      <description>Hi, 
&lt;BR /&gt;Trying to get the destination url of a url like this: 
&lt;A href="http://objects.icecat.biz/objects/mmo-26204092-2358398.html" target="_blank" rel="nofollow noopener noreferrer"&gt;http://objects.icecat.biz/objects/mmo-26204092-2358398.html&lt;/A&gt; 
&lt;BR /&gt;The url redirects to a pdf file.&amp;nbsp;I did manage to get the file with tfilefetch (allowing redirect) but I just need the destination url (simply the url of the pdf file in this case), not the file itself. Any idea's? 
&lt;BR /&gt;Thanks, 
&lt;BR /&gt;Henry</description>
      <pubDate>Tue, 05 May 2015 18:06:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275664#M51969</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2015-05-05T18:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] getting destination url</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275665#M51970</link>
      <description>Hi&amp;nbsp; 
&lt;BR /&gt;There is no a component can be used to get the real url behind a redirect URL right now, however, you can hard code on tJava component to get it, refer to the following pages: 
&lt;BR /&gt; 
&lt;A href="http://www.programminglogic.com/how-to-find-the-real-url-behind-a-redirect-in-java/" rel="nofollow noopener noreferrer"&gt;http://www.programminglogic.com/how-to-find-the-real-url-behind-a-redirect-in-java/&lt;/A&gt; 
&lt;BR /&gt; 
&lt;A href="http://stackoverflow.com/questions/2659000/java-how-to-find-the-redirected-url-of-a-url" rel="nofollow noopener noreferrer"&gt;http://stackoverflow.com/questions/2659000/java-how-to-find-the-redirected-url-of-a-url&lt;/A&gt; 
&lt;BR /&gt;Best regards 
&lt;BR /&gt;Shong</description>
      <pubDate>Wed, 06 May 2015 05:25:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275665#M51970</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-06T05:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] getting destination url</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275666#M51971</link>
      <description>Hi Shong, 
&lt;BR /&gt;Thank you for helping me out, managed to get it working! Only for one url so far... Now I'm trying to get it to work with an input stream (rows come from tExtractXMLField) how should I make it work for all rows? Should I be using tJavaRow instead of tJava? 
&lt;BR /&gt;My code now is: 
&lt;BR /&gt; 
&lt;PRE&gt;String url = row15.url;&lt;BR /&gt;java.net.HttpURLConnection con = (java.net.HttpURLConnection) new java.net.URL(url).openConnection();&lt;BR /&gt;con.setInstanceFollowRedirects(false);&lt;BR /&gt;con.connect();&lt;BR /&gt;String realURL = con.getHeaderField("Location");&lt;BR /&gt;System.out.println(realURL);&lt;/PRE&gt; 
&lt;BR /&gt;The part not yet working is&amp;nbsp; 
&lt;FONT face="consolas, monaco, 'bitstream vera sans mono', 'courier new', courier, monospace"&gt;String url = row15.url;&lt;/FONT&gt;&amp;nbsp; if I'd replace row15.url with " 
&lt;A href="http://myurl.com" rel="nofollow noopener noreferrer"&gt;http://myurl.com&lt;/A&gt;"&amp;nbsp;then the code is working for that url. 
&lt;BR /&gt;Thanks, 
&lt;BR /&gt;Henry</description>
      <pubDate>Thu, 07 May 2015 11:37:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275666#M51971</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2015-05-07T11:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] getting destination url</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275667#M51972</link>
      <description>Yes, if you want access the input data flow, use tJavaRow to replace tJava and change your code to: 
&lt;BR /&gt; 
&lt;BLOCKQUOTE&gt; 
 &lt;TABLE border="1"&gt; 
  &lt;TBODY&gt; 
   &lt;TR&gt; 
    &lt;TD&gt;&lt;FONT size="1"&gt;&lt;FONT face="consolas, monaco, 'bitstream vera sans mono', 'courier new', courier, monospace"&gt;String url = input_row.url;&lt;BR /&gt;java.net.HttpURLConnection con = (java.net.HttpURLConnection) new java.net.URL(url).openConnection();&lt;BR /&gt;con.setInstanceFollowRedirects(false);&lt;BR /&gt;con.connect();&lt;BR /&gt;String realURL = con.getHeaderField("Location");&lt;BR /&gt;System.out.println(realURL);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/TD&gt; 
   &lt;/TR&gt; 
  &lt;/TBODY&gt; 
 &lt;/TABLE&gt; 
&lt;/BLOCKQUOTE&gt; 
&lt;BR /&gt;Shong</description>
      <pubDate>Thu, 07 May 2015 11:55:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275667#M51972</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-07T11:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] getting destination url</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275668#M51973</link>
      <description>Great thanks Shong, that works, it seems I run into 2 small challenges though: 
&lt;BR /&gt;1) IF the input_row.url ends with .html, THEN it needs to perform the code to get the destination url. &amp;nbsp;ELSE output_row.url = input_row.url). Any idea how I should include such a statement in tJavaRow? FYI my current code is: 
&lt;BR /&gt; 
&lt;PRE&gt;String url = input_row.url;&lt;BR /&gt;System.out.println(url);&lt;BR /&gt;java.net.HttpURLConnection con = (java.net.HttpURLConnection) new java.net.URL(url).openConnection();&lt;BR /&gt;con.setInstanceFollowRedirects(false);&lt;BR /&gt;con.connect();&lt;BR /&gt;String realURL = con.getHeaderField("Location");&lt;BR /&gt;System.out.println(realURL);&lt;BR /&gt;output_row.url = realURL;&lt;/PRE&gt; 
&lt;BR /&gt;2) after a numer of connections I get a timeout. I suspect the server on the other side does not accept more than x connections. Could I be missing something in the code above to properly close each connection before going to fetch the next destination url?</description>
      <pubDate>Fri, 08 May 2015 09:50:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275668#M51973</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2015-05-08T09:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] getting destination url</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275669#M51974</link>
      <description>Regarding 1) I don't know whether it's best practice, but it seems I solved including the if statement like this: 
&lt;BR /&gt; 
&lt;PRE&gt;String url = input_row.url;&lt;BR /&gt;System.out.println(url);&lt;BR /&gt;if (StringHandling.INDEX(url,".html")&amp;gt;0){&lt;BR /&gt;java.net.HttpURLConnection con = (java.net.HttpURLConnection) new java.net.URL(url).openConnection();&lt;BR /&gt;con.setInstanceFollowRedirects(false);&lt;BR /&gt;con.connect();&lt;BR /&gt;String realURL = con.getHeaderField("Location");&lt;BR /&gt;System.out.println(realURL);&lt;BR /&gt;output_row.url = realURL;&lt;BR /&gt;}&lt;BR /&gt;else {input_row.url = output_row.url;}&lt;/PRE&gt; 
&lt;BR /&gt;Still open to solve: solving the connection timeout (after x connections it won't accept more)</description>
      <pubDate>Fri, 08 May 2015 10:50:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275669#M51974</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2015-05-08T10:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] getting destination url</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275670#M51975</link>
      <description>Regarding 2) it seems addding con.disconnect(); solves the connection issue. I don't know whether it is best practice to disconnect each time but it works 
&lt;BR /&gt; 
&lt;PRE&gt;//Code generated according to input schema and output schema&lt;BR /&gt;output_row.fk_product_id = input_row.fk_product_id;&lt;BR /&gt;output_row.fk_supplier_id = input_row.fk_supplier_id;&lt;BR /&gt;output_row.id_by_datasupplier = input_row.id_by_datasupplier;&lt;BR /&gt;//&lt;BR /&gt;String url = input_row.url;&lt;BR /&gt;System.out.println(url);&lt;BR /&gt;if (StringHandling.INDEX(url,".html")&amp;gt;0){&lt;BR /&gt;java.net.HttpURLConnection con = (java.net.HttpURLConnection) new java.net.URL(url).openConnection();&lt;BR /&gt;con.setInstanceFollowRedirects(false);&lt;BR /&gt;con.connect();&lt;BR /&gt;String realURL = con.getHeaderField("Location");&lt;BR /&gt;System.out.println(realURL);&lt;BR /&gt;output_row.url = realURL;&lt;BR /&gt;con.disconnect();&lt;BR /&gt;}&lt;BR /&gt;else {input_row.url = output_row.url;}&lt;/PRE&gt; 
&lt;BR /&gt;Shong, or if anyone likes to comment on this, would love to hear, otherwise I'll mark ik resolved later today</description>
      <pubDate>Fri, 08 May 2015 11:22:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275670#M51975</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2015-05-08T11:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] getting destination url</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275671#M51976</link>
      <description>Hi&amp;nbsp; 
&lt;BR /&gt;1) It is OK with this method, you can also use String.endsWith( 
&lt;BR /&gt;) method to check if the url ends with .html. 
&lt;BR /&gt; 
&lt;BLOCKQUOTE&gt; 
 &lt;TABLE border="1"&gt; 
  &lt;TBODY&gt; 
   &lt;TR&gt; 
    &lt;TD&gt;&lt;FONT size="1"&gt;&lt;FONT face="consolas, monaco, 'bitstream vera sans mono', 'courier new', courier, monospace"&gt;String url = input_row.url;&lt;BR /&gt;System.out.println(url);&lt;BR /&gt;if (url.endsWith(".html")){&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;..}&lt;BR /&gt;&lt;/TD&gt; 
   &lt;/TR&gt; 
  &lt;/TBODY&gt; 
 &lt;/TABLE&gt; 
&lt;/BLOCKQUOTE&gt; 
&lt;BR /&gt;2) You need to close the connection at the end, for example: 
&lt;BR /&gt; 
&lt;BLOCKQUOTE&gt; 
 &lt;TABLE border="1"&gt; 
  &lt;TBODY&gt; 
   &lt;TR&gt; 
    &lt;TD&gt;&lt;FONT size="1"&gt;&lt;FONT face="consolas, monaco, 'bitstream vera sans mono', 'courier new', courier, monospace"&gt;if (StringHandling.INDEX(url,".html")&amp;gt;0){&lt;BR /&gt;java.net.HttpURLConnection con = (java.net.HttpURLConnection) new java.net.URL(url).openConnection();&lt;BR /&gt;con.setInstanceFollowRedirects(false);&lt;BR /&gt;con.connect();&lt;BR /&gt;String realURL = con.getHeaderField("Location");&lt;BR /&gt;System.out.println(realURL);&lt;BR /&gt;con.disConnect();&lt;BR /&gt;output_row.url = realURL;&lt;BR /&gt;}&lt;/FONT&gt;&lt;/FONT&gt;&lt;/TD&gt; 
   &lt;/TR&gt; 
  &lt;/TBODY&gt; 
 &lt;/TABLE&gt; 
&lt;/BLOCKQUOTE&gt; 
&lt;BR /&gt;Shong</description>
      <pubDate>Fri, 08 May 2015 11:26:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275671#M51976</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-08T11:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] getting destination url</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275672#M51977</link>
      <description>Many thanks. Used endsWith now and kept disconnect() &amp;nbsp;(without capital C). I'll mark it resolved now</description>
      <pubDate>Fri, 08 May 2015 11:41:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-getting-destination-url/m-p/2275672#M51977</guid>
      <dc:creator>hvanderborg</dc:creator>
      <dc:date>2015-05-08T11:41:22Z</dc:date>
    </item>
  </channel>
</rss>

