Grab contents of a webpage in GWT - gwt

Let's say that I have a link to a webpage that contains some text. What's the easiest way to grab this text to process?
Thanks.

Long story short, I don't think it's possible to make a request from the client js to grab the text from a url with a different domain.
It is possible to make requests to load json. This link describes how.
Basically, the steps are:
Embed a tag in the GWT page
after GWT page is initialized, update
the script tag's src to load remote
url
remote url returns some json data
padded inside a callback javascript
function such as:
callback({blah:foo})
So, you're only option may be writing a method on the server side that loads the url, gets the text. You could then call this method from gwt client using normal rpc technique.

Assuming same origin: use the "RequestBuilder" class.
If you are trying to grab a webpage from a different origin, then it obviously won't work.

Related

How do I rewrite URL to drop file extension for pdf on github pages?

Imagine my website is hosted on GitHub Pages and has a custom domain website.com. I can access a pdf at website.com/mypdf.pdf
Is there a way where I can make it work at website.com/mypdf?
As mentioned in comments, if you are using static website hosted by a 3rd party like GitHub pages, you don't really get a lot of control over http server. I would tentatively say you cannot control URL rewrite rules on GitHub.
What you could potentially do instead is to host a page with a bit of JavaScript that would start the download on a given event (button click, page load, etc) this way you could mask your actual download URL with this html page (that by convention comes with no file extension)
UPD: and surely enough someone's been doing it already: http://lea.verou.me/2016/11/url-rewriting-with-github-pages/. The post is going on about having nice urls, but I believe file downloads implementation can be implemented similarly
Yes you should make your website with MVC structure. Make a controller and in Index action load pdf file.
Then on action calling your pdf will be loaded like that:
Students/AllResult etc

When to use "Follow Redirects" & "Redirect Automatically" while recording with jmeter.

I want to know the difference between Follow Redirects and Redirect Automatically while recording with Jmeter.
Also what effect will both these have when used with Retrieve all Embedded Resources from HTML
Redirect automatically, will not consider redirect as a separate request
where as Follow redirects will consider each redirection as a separate request.
This difference can be visualized in the Listener (View Results Tree).
If Retrieve all Embedded Resources from HTML is checked, it will give you Page Load Time, since apart from response time it will keep on calculating the time taken till all the supporting files of html page have been downloaded to Local (CSS, Images, Javascript files.. etc.)
Also if any values needs to be captured from redirect request you need to set configuration a follow redirect otherwise will not be able to capture those data using extractors (set cookie values for example)
Hope this will help.

How to secure querystring/POST details to a third party

I'm basically looking at a security problem between a parent page and an iframe with links to a third party.
I want to send a POST or a GET (doesn't matter which as I can control the other side) to the third party, but not expose any details within it (say a SID or a user token) and have it's HTML content (JS/HTML/Images) loaded into the iframe.
I've looked at server-side redirects, creating a proxy using webclinet/webresponse and am curious to whether there is a good way to do it.
Has anyone ever done this before, or think that the secrity is not possible? Hell, even if I'm barking up the wrong tree on how to solve this.
If anybody has any examples on this it would be greatly appreciated.
Cheers,
Jamie
[Edit] Was thinking I might need to add some more details.
Say I have a parent page: https://mycompany.com/ShowThirdParty.
This has an iframe in it at the moment which will have the content of another component (also owned by me, or another team more specifically)
Basically I'd like to send some credentials to content in the iframe in such a way that the external pages can't read it, the iframe is put into a modal (I've done that) and the iframe has the restricted content with the auhtentication almost seamless and invisible.
I currently have it working as a GET url generated dynamically via JS and then passed into the iframe src parameter, obviously that isn't secure.
I kind of want some kind of server side redirect across a full url, but I don't even think that's possible.
You could try using AJAX and load a PHP script (with any parameters to the script encoded/encrypted) to query the 3rd party page and load the response into the iframe. Not really sure how your code is setup but there should be a way.
It can also be done by POST Method (submit the data to iFrame using POST) as it is HTTPS so the data you send to iFrame is encryped.

Can I get the source of the current Wicket Page?

I've been using wicketTester.getServetResponse.getDocument to get the text of the current page for testing, only to find that after an ajax request it is set to the ajax response, not the whole page.
Is there any way to get a representation of the whole rendered page, as the browser would be seeing it after the ajax manipulation?
With WicketTester, you can simulate an Ajax call and see that your app sends the correct Ajax response. But it doesn't really exercise the ajax.
So I don't believe there's a way to get that from WicketTester.
If you actually need to test the app all the way to the UI including Ajax/javascript effects on the rendering, you likely need to use something like Selenium for that portion of your testing.
Thinking the Wicket way I hope the following approach should work:
#startPage(YourPage.class)
do some Ajax calls
#startPage(wicketTester.getLastRenderedPage())
wicketTester.getLastRenderedPageAsString()
The idea is: you start a page for testing, the first response is complete page response, then you do some Ajax calls which change some models around, then you start the last rendered page as an instance - this way it will render the page with the updated models from the Ajax calls.
The trouble is that you can put any Javascript in the response to an Ajax call. But if you don't want to deal with that, you can save the original full-page DOM, iterate through the objects in the Ajax response, find them by id in the full DOM and replace them with the new versions.
How useful this would be, I don't know, my guess would be not very. so I'd probably go with Selenium too.

How does facebook's Share a link feature work?

I'm trying to implement a feature like that where a user inputs a url and when displaying that url I want to have a custom display (an embed object if it's a video from youtube, a thumbnail if it's an image link, title and excerpt of body if it's a normal link).
How can such a feature be realized?
There is a new idea called oEmbed that a few sites support (Flickr, Vimeo and a few others) that addresses this problem. oEmbed site
Otherwise, just check the site against a list of ones you pick and then pull out the relevant bits to construct an embed link.
I liked the idea of oEmbed a lot but unfortunately it doesn't has that much adoption yet.
oohEmbed tries to solve this issue by building oEmbed for many websites.
For the feature to work, it needs the server's interaction where I believe the following scenario is how it works
Assume that we have the site humanzz.com and that it provides such feature
A user enters a url on the humanzz.com's webpage and presses a button like facebooks' preview button
An AJAX call is made to a dedicated page on humanzz.com
humanzz.com does calls the remote website and gets its data
The AJAX call now returns the page's data (oEmbed JSON object)
This involves so much server's overhead.
I really wanted to do it using JavaScript as the server's role was only to bypass "Same Origin Policy"'s restrictions.
oohEmbed allows bypassing the server's step by specifying a callback parameter to oohEmbed so that the JSON object returned is passed to a callback function on your page.
An example illustrating this is as follows
Add a script tag dynamically to your page
< script type="text/javascript" src="http://oohembed.com/oohembed/?url=http%3A//www.amazon.com/Myths-Innovation-Scott-Berkun/dp/0596527055/&callback=myCallBack">< /script>
This would result in executing myCallback(oEmbedJSONObject) which is great.
The problem with that solution is you still have to have a fallback for websites that don't have oEmbed representations.
For the embedded things, I have been using auto_html ( https://github.com/dejan/auto_html) with great success (vimeo, youtube, images) and even added soundcloud myself. But I am still looking for a "thumbnail" generation with an image and text facebook-like.
I guess you have to construct it by yourself by manually parsing the kind of URL you get.
If it is an image url, well then you just have to rescale it and in case the user clicks on it, then handle that by opening the original one somehow.
If it is a link to some youtube video, then you have to take a look at how the embedding of Youtube videos works. You can just copy the code that is provided by Youtube itself, and then exchange the parts with the URL to the video with the URL you got from your user.
I did never implement something like that, but I assume it should work somehow like this.