Split on pipe doesn't behave as expected - java

I have a code that get a HTML content from a page, then get the index of a specific strings, after that it splits it.
My problem is, It's not splitting right, Plus it's getting unwanted Strings .
Code :
URL = "https://drive.google.com/file/d/0B7--EhvK76QDRktKZm04MXVjVTQ/view";
html = Jsoup.connect(URL).get().html();
FirstDecoded = URLDecoder.decode(html, "UTF-8");
int Start = FirstDecoded.indexOf("[\"fmt_stream_map\"");
int End = FirstDecoded.indexOf("\"fmt_list\"");
String FirstSplit = FirstDecoded.substring(Start + 22, -5 + End);
String[] DummyTexts = {"<html>","<head>","</head>","<body>","</body>","</html"};
if(FirstSplit.contains(DummyTexts[0]))
FirstSplit.replace(DummyTexts[0],"");
if(FirstSplit.contains(DummyTexts[1]))
FirstSplit.replace(DummyTexts[1],"");
if(FirstSplit.contains(DummyTexts[2]))
FirstSplit.replace(DummyTexts[2],"");
if(FirstSplit.contains(DummyTexts[3]))
FirstSplit.replace(DummyTexts[3],"");
if(FirstSplit.contains(DummyTexts[4]))
FirstSplit.replace(DummyTexts[4],"");
FirstSplit.trim();
String[] Splitted = FirstSplit.split("|");
What i want :
Before Split
Url|Url|Url|Url
After Split
[0] = URL
[1] = 2nd URL
Result (What i don't want ) :
<!html>*a new line*<head></head>*a new line*<body>*a new line**white space*URL|URL|URL*a new line**2 White Space*</body></html>
If i try to split it, [0] is null, [1] is <! .
The HTML is :
<!doctype html>
<html>
<head>
<meta name="google" content="notranslate">
<meta http-equiv="X-UA-Compatible" content="IE=edge;">
<meta name="fragment" content="!">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
<title>OnClick.mp4 - Google Drive</title>
<meta property="og:title" content="OnClick.mp4">
<meta property="og:type" content="article">
<meta property="og:site_name" content="Google Docs">
<script>(function(){(function(){function e(a){this.t={};this.tick=function(a,c,b){var d=void 0!=b?b:(new Date).getTime();this.t[a]=[d,c];if(void 0==b)try{window.console.timeStamp("CSI/" a)}catch(e){}};this.tick("start",null,a)}var a;window.performance&&(a=window.performance.timing);var f=a?new e(a.responseStart):new e;window.jstiming={Timer:e,load:f};if(a){var c=a.navigationStart,d=a.responseStart;0<c&&d>=c&&(window.jstiming.srt=d-c)}if(a){var b=window.jstiming.load;0<c&&d>=c&&(b.tick("_wtsrt",void 0,c),b.tick("wtsrt_",
"_wtsrt",d),b.tick("tbsd_","wtsrt_"))}try{a=null,window.chrome&&window.chrome.csi&&(a=Math.floor(window.chrome.csi().pageT),b&&0<c&&(b.tick("_tbnd",void 0,window.chrome.csi().startE),b.tick("tbnd_","_tbnd",c))),null==a&&window.gtbExternal&&(a=window.gtbExternal.pageT()),null==a&&window.external&&(a=window.external.pageT,b&&0<c&&(b.tick("_tbnd",void 0,window.external.startE),b.tick("tbnd_","_tbnd",c))),a&&(window.jstiming.pt=a)}catch(g){}})();})();
</script>
<script>window.gapi_onload=function(){};var scriptEl$$inline_0=document.createElement("script");scriptEl$$inline_0.src="https://apis.google.com/js/client.js";scriptEl$$inline_0.async=!0;var firstScriptEl$$inline_1=document.getElementsByTagName("script")[0];firstScriptEl$$inline_1.parentNode.insertBefore(scriptEl$$inline_0,firstScriptEl$$inline_1);
</script>
<link rel="shortcut icon" href="https://ssl.gstatic.com/docs/doclist/images/icon_14_video_favicon.ico">
<link rel="stylesheet" href="/static/file/client/css/2745349237-projector_css_rtl.css">
<script>_docs_flag_initialData={"docs-aiiws":"docs_cold_nf","docs-ails":"docs_cold","docs-fwds":"docs_nf","info_params":{},"docosEmbedApiJs":"//docs.google.com/comments/d/AAHRpnXuhyO5yfTCPldRcxO-Xq_Srdd0JamOO8LslEPvYPeUzPnTtftedmIsqUWcNeSJHWF2hg2WdKe4Zpf5PRuBTzieIUoGG1g/api/js?hl\u003dar","docosUnreadCommentsEnabled":false,"uls":"","icso":false,"docs_oogt":"NONE","docs-egc":true,"docs-chat_wabel":false,"docs-ce":true,"docs-ut":2,"docs-chat_base_url":"talkgadget.google.com/talkgadget/","docs-chat_domain_rotation":true,"docs-cwd":"","docs-epuv2":false,"promo_url":"","promo_title":"","promo_title_prefix":"","promo_content_html":"","promo_link_text":"","promo_element_id":"","promo_orientation":1,"promo_show_on_click":false,"promo_show_on_load":false,"show_promo":false,"promo_mark_dismissed_on_show":false,"promo_use_global_preference":false,"promo_close_button_text":"","docs-encp":false,"buildLabel":"texmex_2016.05-Thu_RC0","docs-show_debug_info":false,"ondlburl":"//docs.google.com","drive_url":"//drive.google.com","app_url":"https://drive.google.com/file/","docs-mid":2048,"docs-eicd":false,"docs-icdmt":[],"docs-sup":"/file","docs-uptc":["lsrp","noreplica","usp","urp","utm_source","utm_medium","utm_campaign","utm_term","utm_content","sle"],"docs-cwsd":"","docs-al":[0,0,0,1,0],"docs-ndt":"Untitled Texmex","docs-rpe":false,"docs-mdck":"","docs-mas":"","docs-etiff":false,"docs-spfe":true,"docs-mriim":1800000,"docs-eccbs":false,"docs-net-ernjp":false,"docos-sosj":false,"docs-rlmp":false,"docs-mmpt":15000,"docs-erd":false,"docs-erfar":false,"docs-ssi":false,"docs-ema":false,"docs-escd":false,"docs-ensb":false,"docs-epwf":false,"ecid":true,"docs-emo":false,"docs-eos":false,"docs-pedd":true,"docs-eir":false,"docs-dc":false,"docs-edll":false,"docs-eivu":false,"server_time_ms":1455582166639,"gaia_session_id":"","app-bc":"#d1d1d1","enable_iframed_embed_api":true,"docs-fut":"//drive.google.com#folders/{folderId}","esid":true,"esubid":false,"docs-etbs":true,"docs-isb":false,"docs-pid":"","docs-mib":5242880,"docs-mip":6250000,"enable_kennedy":true,"docs-gth":"","opendv":false,"onePickImportDocumentUrl":"","opmbs":5242880,"opmpd":2500,"opbu":"https://docs.google.com/picker","opru":"https://drive.google.com/relay.html","opdu":false,"opccp":false,"ophi":"texmex","opst":"000770F2037BC252B6F708ED31726B33CE13CDBE7A86BF0E7B","opuci":"","jobset":"prod","docs-se":false,"docs-ebcrsct":false,"docs-iror":true,"enable_client_docos":true,"enable_anchored_docos":true,"enable_docos_tickle":true,"enable_pinned_revisions":false,"enable_edit_blob_revisions":false,"upload_url":"https://docs.google.com/upload/resumableupload","enable_toolbar":true,"enable_link_opener":true,"enable_microscope":true,"enable_manage_timed_text":true,"video_embed_type":"PREFER_FLASH","enable_maps_embed":false,"maps_api_uri":"https://maps.googleapis.com/maps/api/js?key\u003dAIzaSyBCjpnguVjzi6vS67NdBtyYuvCYz3yBxCY&sensor\u003dfalse","maps_display_uri":"https://maps.google.com/maps","docs-epcc":false,"docs_abuse_link":"https://docs.google.com/abuse?id\u003d0B7--EhvK76QDRktKZm04MXVjVTQ","enable_csi":true,"csi_service_name":"texmex","third_party_default_icon_urls":{"icon16":"//ssl.gstatic.com/docs/doclist/images/generic_app_icon_16.png","icon32":"//ssl.gstatic.com/docs/doclist/images/generic_app_icon_32.png","icon64":"//ssl.gstatic.com/docs/doclist/images/generic_app_icon_64.png","icon128":"//ssl.gstatic.com/docs/doclist/images/generic_app_icon_128.png"},"enable_chrome_webstore_link":true};</script>
</head>
<body dir="rtl" role="application" onload="_onProjectorLoad();" onunload="_disposeProjector();">
<meta itemprop="name" content="OnClick.mp4">
<meta itemprop="faviconUrl" content="https://ssl.gstatic.com/docs/doclist/images/icon_14_video_favicon.ico">
<script type="text/javascript" src="/static/file/client/js/2068619951-projector_viewer__ar.js"></script>
<script>_initProjector({'id': '0B7--EhvK76QDRktKZm04MXVjVTQ', 'title': 'OnClick.mp4','isMobileWeb': true,'enableStandaloneSharing': true,'enableEmbedDialog': true,'projectorFeedbackId': '99950', 'projectorFeedbackBucket': 'viewer-web',},["",0,,1,1,1,1,,,1,0,[0,,0,"AIzaSyDVQw45DwoYh632gvsP5vPDqEKvb-Ywnb8",0,0,1,0,,,0,"/drive/v2internal",0,0,0,[0,0,0]
,0,1]
,1,5,1,,0,1,"https://docs.google.com",0,1,1,1,1,,1,20,1,0,0,1,1,[[,"0"]
,6,1,1,"ND"]
,0,0,1,,[0,,,,"https://accounts.google.com/ServiceLogin?service\u003dwise&passive\u003d1209600&continue\u003dhttps://drive.google.com/file/d/0B7--EhvK76QDRktKZm04MXVjVTQ/view&hl\u003dar&followup\u003dhttps://drive.google.com/file/d/0B7--EhvK76QDRktKZm04MXVjVTQ/view"]
,0,1,1,600000,,"https://docs.google.com",0,0,[0,1,1,1]
,["https://youtube.googleapis.com",1,2]
,1,1,,0,1,1,1,0,,,,,[1,1,1,1]
,,1,0,2,0,0,[0,"https://maps.googleapis.com/maps/api/js?key\u003dAIzaSyBCjpnguVjzi6vS67NdBtyYuvCYz3yBxCY&sensor\u003dfalse"]
,0]
,[,"OnClick.mp4","https://lh4.googleusercontent.com/pI9y-A5tCOzi0W7eYAMzgqPHfzuBbq2wno4s2mvkrgc-JNtHtHWU36w0iICXMsRjxaAFuJ0p\u003dw1600-rw",,,,"0B7--EhvK76QDRktKZm04MXVjVTQ",,,,,"video/mp4",,,0,,"https://drive.google.com/file/d/0B7--EhvK76QDRktKZm04MXVjVTQ/view",1,"https://docs.google.com/uc?id\u003d0B7--EhvK76QDRktKZm04MXVjVTQ&export\u003ddownload",[[["status","ok"]
,["hl","ar"]
,["allow_embed","0"]
,["ps","docs"]
,["partnerid","30"]
,["autoplay","0"]
,["docid","0B7--EhvK76QDRktKZm04MXVjVTQ"]
,["abd","0"]
,["public","true"]
,["el","leaf"]
,["title","OnClick.mp4"]
,["BASE_URL","https://drive.google.com/"]
,["iurl","https://docs.google.com/vt?id\u003d0B7--EhvK76QDRktKZm04MXVjVTQ"]
,["ttsurl","https://drive.google.com/timedtext?id\u003d0B7--EhvK76QDRktKZm04MXVjVTQ&vid\u003d1089c9d5a380c541"]
,["reportabuseurl","https://drive.google.com/abuse?id\u003d0B7--EhvK76QDRktKZm04MXVjVTQ"]
,["token","1"]
,["plid","V0QUM0REiMM2sQ"]
,["fmt_stream_map","37|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d37&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d3DC24BBB45AB0C09B1633ABC215282DAD3275086.1E524A3C98B38084443AF227B4676FA122CB7191&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18,22|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d22&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d92CE58A6991267C1E6F28C23DC9C03F5CF7E0C7A.77E9DBA8D81F681587D68E2C9EF942DAA37D8461&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18,35|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d35&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d92E5A471515BC4145F258D67C6E52F7CA0FA2530.73516C4866808CD98769225F3623A93613B65F1E&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18,59|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d59&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d66DCB19D441D9742A4D21F1A08CDF488C81F728D.1864D7646337ED87C9A82951A0D524B6B3CEF451&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18,34|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d34&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d1837C0B9C77AF259371C0239C7B56C68C43B86A0.68E22AF960C1C023033FD24D1138AFBE91CD02D3&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18,18|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d18&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d9208D71BE0BCBE4B3DF1E7B922159C3BE921FA05.2A991F268E18F480929B6A98B107468601A55535&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18,43|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d43&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d5720BE679324A8AE30BA464F81AE61CB6A551C1.69D6E187577E285BF9C2BF0415AD929EFA212D45&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18"]
,["fmt_list","37/1920x1080/9/0/115,22/1280x720/9/0/115,35/854x480/9/0/115,59/854x480/9/0/115,34/640x360/9/0/115,18/640x360/9/0/115,43/640x360/99/0/0"]
,["url_encoded_fmt_stream_map","itag\u003d37&url\u003dhttps://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl=yes&id=1089c9d5a380c541&itag=37&source=webdrive&app=texmex&ip=5.0.148.212&ipbits=8&expire=1455596566&sparams=requiressl,id,itag,source,ip,ipbits,expire&signature=3DC24BBB45AB0C09B1633ABC215282DAD3275086.1E524A3C98B38084443AF227B4676FA122CB7191&key=ck2&mm=30&mn=sn-hpa7ln7k&ms=nxu&mt=1455582034&mv=m&pl=18&type\u003dvideo/mp4; codecs="avc1.42001E, mp4a.40.2"&quality\u003dhd1080,itag\u003d22&url\u003dhttps://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl=yes&id=1089c9d5a380c541&itag=22&source=webdrive&app=texmex&ip=5.0.148.212&ipbits=8&expire=1455596566&sparams=requiressl,id,itag,source,ip,ipbits,expire&signature=92CE58A6991267C1E6F28C23DC9C03F5CF7E0C7A.77E9DBA8D81F681587D68E2C9EF942DAA37D8461&key=ck2&mm=30&mn=sn-hpa7ln7k&ms=nxu&mt=1455582034&mv=m&pl=18&type\u003dvideo/mp4; codecs="avc1.42001E, mp4a.40.2"&quality\u003dhd720,itag\u003d35&url\u003dhttps://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl=yes&id=1089c9d5a380c541&itag=35&source=webdrive&app=texmex&ip=5.0.148.212&ipbits=8&expire=1455596566&sparams=requiressl,id,itag,source,ip,ipbits,expire&signature=92E5A471515BC4145F258D67C6E52F7CA0FA2530.73516C4866808CD98769225F3623A93613B65F1E&key=ck2&mm=30&mn=sn-hpa7ln7k&ms=nxu&mt=1455582034&mv=m&pl=18&type\u003dvideo/x-flv&quality\u003dlarge,itag\u003d59&url\u003dhttps://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl=yes&id=1089c9d5a380c541&itag=59&source=webdrive&app=texmex&ip=5.0.148.212&ipbits=8&expire=1455596566&sparams=requiressl,id,itag,source,ip,ipbits,expire&signature=66DCB19D441D9742A4D21F1A08CDF488C81F728D.1864D7646337ED87C9A82951A0D524B6B3CEF451&key=ck2&mm=30&mn=sn-hpa7ln7k&ms=nxu&mt=1455582034&mv=m&pl=18&type\u003dvideo/mp4; codecs="avc1.42001E, mp4a.40.2"&quality\u003dlarge,itag\u003d34&url\u003dhttps://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl=yes&id=1089c9d5a380c541&itag=34&source=webdrive&app=texmex&ip=5.0.148.212&ipbits=8&expire=1455596566&sparams=requiressl,id,itag,source,ip,ipbits,expire&signature=1837C0B9C77AF259371C0239C7B56C68C43B86A0.68E22AF960C1C023033FD24D1138AFBE91CD02D3&key=ck2&mm=30&mn=sn-hpa7ln7k&ms=nxu&mt=1455582034&mv=m&pl=18&type\u003dvideo/x-flv&quality\u003dmedium,itag\u003d18&url\u003dhttps://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl=yes&id=1089c9d5a380c541&itag=18&source=webdrive&app=texmex&ip=5.0.148.212&ipbits=8&expire=1455596566&sparams=requiressl,id,itag,source,ip,ipbits,expire&signature=9208D71BE0BCBE4B3DF1E7B922159C3BE921FA05.2A991F268E18F480929B6A98B107468601A55535&key=ck2&mm=30&mn=sn-hpa7ln7k&ms=nxu&mt=1455582034&mv=m&pl=18&type\u003dvideo/mp4; codecs="avc1.42001E, mp4a.40.2"&quality\u003dmedium,itag\u003d43&url\u003dhttps://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl=yes&id=1089c9d5a380c541&itag=43&source=webdrive&app=texmex&ip=5.0.148.212&ipbits=8&expire=1455596566&sparams=requiressl,id,itag,source,ip,ipbits,expire&signature=5720BE679324A8AE30BA464F81AE61CB6A551C1.69D6E187577E285BF9C2BF0415AD929EFA212D45&key=ck2&mm=30&mn=sn-hpa7ln7k&ms=nxu&mt=1455582034&mv=m&pl=18&type\u003dvideo/webm&quality\u003dmedium"]
,["timestamp","1455582166637"]
,["length_seconds","19"]
]
]
,5,0,,,,,,,,,,1,"mp4"]
);</script>
</body>
</html>

Not spending too much time looking at your logic, I can see that you think
FirstSplit.replace(DummyTexts[0],"");
actually changes the String FirstSplit, which it doesn't. In Java Strings are immutable, so they can't change.
Replace all those lines with something like this (obviously with different indexes in DummyTexts):
FirstSplit = FirstSplit.replace(DummyTexts[0], "");
Note that this doesn't change FirstSplit, it just changes what String FirstSplit refers to, setting it to the new String being returned by the replace method. That might get you what you want, assuming the rest of that stuff works.
Ok, you say you changed to this and it still didn't work. That's probably because the FirstDecoded string you're creating is basically the fmt_stream_map line from the HTML you listed (minus a few characters at the front and back):
"fmt_stream_map","37|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d37&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d3DC24BBB45AB0C09B1633ABC215282DAD3275086.1E524A3C98B38084443AF227B4676FA122CB7191&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18,22|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d22&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d92CE58A6991267C1E6F28C23DC9C03F5CF7E0C7A.77E9DBA8D81F681587D68E2C9EF942DAA37D8461&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18,35|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d35&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d92E5A471515BC4145F258D67C6E52F7CA0FA2530.73516C4866808CD98769225F3623A93613B65F1E&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18,59|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d59&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d66DCB19D441D9742A4D21F1A08CDF488C81F728D.1864D7646337ED87C9A82951A0D524B6B3CEF451&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18,34|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d34&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d1837C0B9C77AF259371C0239C7B56C68C43B86A0.68E22AF960C1C023033FD24D1138AFBE91CD02D3&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18,18|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d18&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d9208D71BE0BCBE4B3DF1E7B922159C3BE921FA05.2A991F268E18F480929B6A98B107468601A55535&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18,43|https://r13---sn-hpa7ln7k.c.docs.google.com/videoplayback?requiressl\u003dyes&id\u003d1089c9d5a380c541&itag\u003d43&source\u003dwebdrive&app\u003dtexmex&ip\u003d5.0.148.212&ipbits\u003d8&expire\u003d1455596566&sparams\u003drequiressl,id,itag,source,ip,ipbits,expire&signature\u003d5720BE679324A8AE30BA464F81AE61CB6A551C1.69D6E187577E285BF9C2BF0415AD929EFA212D45&key\u003dck2&mm\u003d30&mn\u003dsn-hpa7ln7k&ms\u003dnxu&mt\u003d1455582034&mv\u003dm&pl\u003d18"] ,[
This doesn't have any of the strings you're looking for in it....
Ok, so now you're wondering why splitting the whole page gives you crazy results, and it's because split() takes a regex argument, not just a String. A single pipe '|' is not valid regex, use "\|" instead (escaped the special character).
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String)

Related

Replace start and end text with empty

I have html like bellow
<html lang="en">
<head>
<meta http-equiv ...............
...................
</head> ..............
...............
</html>
I want to replace <head>.....</head> with ""(empty) and final string should look like this
<html lang="en">..............
....................
</html>
I tried with this but no luck nothing changed. any help is appreciated
myStr= myStr.replaceAll("^<head>.*</head>$", "");
System.out.println(myStr);
<head>\\s*([\\s\\S]*?)\\s*<\\/head>
You will have to replace by $1 here.See demo.
https://regex101.com/r/uF4oY4/20
Try This
String replStr = "<head>\\s*([\\s\\S]*?)\\s*</head>";
String yourHtml = "<html> <head> <meta http-equiv ............</head></html>";
yourHtml = yourHtml.replaceAll(replStr, "");
System.out.println("Ans : "+yourHtml);

Unable to decode utf-8 using thai language?

This is my JSP page:
<%--
Document : new jsp1
Created on : Nov 24, 2014, 12:38:07 PM
Author : Java
--%>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String msg="206_John_help i m in trouble,delhi,อินเดีย_30.64741430_76.817313799";
String result = java.net.URLEncoder.encode(msg, "UTF-8");
System.out.println("The msg is "+result);
String result1=java.net.URLDecoder.decode(result, "UTF-8");
System.out.println("The decoded msg is "+result1);
%>
</body>
</html>
The output is 206_John_help i m in trouble,delhi,???????_30.64741430_76.817313799
I am always getting ?????? instead of thai alphabets. How can I get the Thai alphabets while decoding?
The problem is not on encoding and decoding the messages but in the server container. Seems that server cant display properly the special characters, so it can not treat them from request.
If you display the values in the JSP page itself, everything is working fine.
Example:
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String msg="206_John_help i m in trouble,delhi,อินเดีย_30.64741430_76.817313799";
System.out.println("The original message "+msg);
String result = java.net.URLEncoder.encode(msg, "UTF-8");
System.out.println("The msg is "+result);
String result1=java.net.URLDecoder.decode(result, "UTF-8");
System.out.println("The decoded msg is "+result1);
%>
Original message <%=msg %><br />
Encrypted message <%=result %> <br />
Decrypted message <%=result1 %>
</body>
</html>

jsp: how to get value from session?

I get an String array from session and I want to show the String from the array.
I know javascript can't get data from session directly. Is there any method I can get the data from session and transfer it to javascrip?
My code as follows:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%String[] sele = (String[])session.getAttribute("selections");%>;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Expires" content="0">
<meta http-equiv="kiben" content="no-cache">
<title>Check List</title>
<script language="javascript" type="text/JavaScript" src="cookie.js">
</script>
<script text="text/javascript">
{
var selections = //String array form session
for(var v=0;v<selections.length;v++){
fillForm(selections[v]);
}
}
function fillForm(name){
var checkbox= document.createElement("input");
checkbox.type="checkbox";
checkbox.name=name;
checkbox.value=name;
checkbox.id=name;
var label = document.createElement("label");
label.htmlFor="id";
label.appendChild(document.createTextNode(name));
var container = document.getElementById("checklist");
container.appendChild(checkbox);
container.appendChild(label);
container.appendChild(document.createElement("br"));
}
function submitAction(){
addUserName(document.getElementById("checklist"));
var elem = document.getElementById("checklist").elements;
for(i =0;i<elem.length;i++){
elem[i].checked = true;
}
var form = document.getElementById("checklist");
form.submit();
}
</script>
</head>
<body>
<form id="checklist" action="selection">
</form>
<Button type="button" onclick="submitAction()" name="submit">Submit</button>
</body>
</html>
Simply use JSP Expression Language and JSP JSTL
<script>
alert("value: ${selections}");
</script>
Here selections is an attribute that is set in any scope page, request, session or application.
You can directly access an attribute form session scope:
{sessionScope.selections}
Note: I don't know that Java ArrayList does work in JavaScript as well. If it doesn't work then simply set a comma separated string as session attribute and split it in JavaScript as shown below.
Sample code:
<script>
var selections = "${sessionScope.csv}".split(",");
for ( var v = 0; v < selections.length; v++) {
alert(selections[v]);
}
</script>
Here csv is a comma separated string value that is set in session scope.
Use JSP JSTL and EL instead of Scriplet that is more easy to use and less error prone.
You can achieve it in JSTL without using JavaScript. Simply iterate the list using <c:forEach> tag and add that much of check boxes and labels.
Sample code:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
...
<body>
...
<c:forEach items="${selections }" var="name">
<input type="checkbox" name="${name}" value="${name}" id="${name}">
...
</c:forEach>
</body>

How to use jsp variable in javascript array?

Hi I have a jsp page where I have some variable. I want to access the variable in a javascript array. How can I get this?
Demo.jsp
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
int i=1;
int j=2;
int k=3;
int l=4;
%>
</body>
</html>
I want to use these 4 variables in the javascript array and print them.
How can I achieve this?
Try,
<script language="JavaScript">
var Arr = new Array();
Arr[0] = '<%=i %>';
Arr[1] = '<%=j %>';
Arr[2] = '<%=k %>';
Arr[3] = '<%=l %>';
</script>
In Java script you have to use scriplet tag to use jsp data.
<%
Integet a = i ; //here i is your jsp variable
%>
In order to make this work you should declare the variable before using it (as always):
<%
String myVar="blabla";
%>
<script type="text/javascript">
foo();
function foo() {
var value = "<%=myVar%>";
alert(value);
}
</script>
Or :
var result = [];
result.push(<%i%>);
result.push(<%j%>);
result.push(<%k%>);
result.push(<%l%>);
You can access it using JSTL.
set java variable to JSTL variable
Access it in Java script as
var x='${jstl_varialbe_goes_here
}';
alert(x);

Why isn't JSP out.print() function working properly

I've been working with a JSP+Java+Html, and I've encountered a problem with out.print() function, in a for cycle.
My function getGeneAvailableTaxonomies() returns a list of integer numbers (of type List<Integer>), and I want to print these numbers in an interface.
Here's my code:
for(Integer i : ApplicationExtender.getApplicationExtender(application).getGeneAvailableTaxonomies())
{
out.print(String.format("<option value=\"%1$d\">%2$s</option>", i, TaxonId.getOrganismFromId(i)));
}
The doce %1$d should stand for the i integer value, while %2$s should stand for the other parameter, the taxonomy id value as String.
But, unfortunately, this is what appears:
While I would like to see something like:
There's surely an error on my out.print() function call... but what's wrong?
Many thanks
You dont need the "$" in your format String. As you may know, using scriptlets is not a good way to do Java Web Development. I think that using JSTL is far better, as you won't mix Java code with markup in your JSP's.
Edit: The printf method is not present in out object as I said earlier, since it is a JspWriter and JspWriter not inherit from PrintWriter (that have printf). Sorry. So, try this (it worked for me).
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<select>
<%
String[] strings = new String[]{ "aaa", "bbb", "ccc", "ddd" };
for ( int i = 0; i < strings.length; i++ ) {
out.print( String.format( "<option value='%d'>%s</option>", i, strings[i] ) );
}
%>
</select>
</body>
</html>
If you want to use a PrintWriter as in Servlets, so this will work:
<%#page import="java.io.PrintWriter"%>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<select>
<%
PrintWriter writer = new PrintWriter( out );
String[] strings = new String[]{ "aaa", "bbb", "ccc", "ddd" };
for ( int i = 0; i < strings.length; i++ ) {
writer.printf( "<option value='%d'>%s</option>", i, strings[i] );
}
%>
</select>
</body>
</html>
Your print/format code seems OK when I run it on http://ideone.com/u8fDT. You probably just need to have the JSP recompiled (should probably happen automatically but may sometimes require server restart).
Also, mixing HTML and Java code like this is a pretty painful way to work. JSTL or a templating system like FreeMarker would make your life easier.
try this as much i have understood :
String option = "<option value=\""+d+"\">"+s+"</option>";
out.print(option);
using String.format
out.print(String.format("<option value=\"%d\">%s</option>", i, TaxonId.getOrganismFromId(i)));
Updated
as you have mentioned in comments that TaxonID.getOrganismFromId(i) is returning int so the there is only one change in your original code %2$s to %2$d thats it...
out.print(String.format("<option value=\"%1$d\">%2$d</option>", i, TaxonId.getOrganismFromId(i)));

Categories