I want to create an application that uses a shipping calculator on an external web page (http://www.bring.no/page?id=4994) to calculate a shipping.
The scenario will be that a user will fill out the fields, then he will have to submit, which will use the page's shipping calculator, then get the value (the shipping fee).
So basically what I want to make is a swing application that looks similar to the existing shipping calculator, pass arguments to it, and retrieve the result.
I have no idea how to do this. So any tips or hints would be highly appreciated! :)
Look at Apache HttpClient for communicating with websites and webservices from your Java Swing application.
You have to do an HTTP POST with the field names on the web page.
HttpClient mentioned by Jonas is fine and very good for complicated tasks because it is almost web browser. It supports sessions, cookies, HTTP headers etc. But in your case the task seems very simple and it is enough to use URL + URLConnection from JDK.
Related
I have AngularJS application already in production and I need to make it Google-friendly. I have read about Ajax crawling mechanism and I have following two problems:
1. Since I have backend written in Java, I have tried HtmlUnit to make static snapshots, but it didn't work well with AngularJS. How can I serve snapshots of my AngularJS pages using Java?
2. As I have mentioned, application is already published and it uses simple hash without !. E.g.: /#/about, /#/home. Is it possible to keep this scheme? Change to /#!/ would require modifications of all links and would break all existing links (posted on web).
Thanks in advance!
The SEO is always an issue with single-page application.
I suggest you make a quick implementation of Phantom.js to display already rendered page to google bots. Check out this link for more informations.
Phantom.js will be a gateway to which you redirect every indexing bot request, it will then render your app like a normal user will do, and then send back the rendered page to the bot.
Also, it would be better to change your /#/ to only /, it's better for your users and also SEO. You just need to redirect every request to the index.html page and to use '/#/' as fallback for old browser which doesn't support pushState.
You also have some paid solution like https://prerender.io/ which works beautifuly.
I'm working on a project which needs to parse some data from some protected web pages. In order to gain the access those pages, I have to overcome a SAML authetication form (Shibboleth).
Is there someone who was able to implement this standard in Android (Java)?
I already read this thread: SAML Client implementation for Android?
but it doesn't give me a good solution. In fact, I need to get the data of some protected web pages in order to parse it, not to let the user to see the content of such pages. Therefore logging in through a WebView is not what I really need..
I think OpenSAML is your best bet for handling the SAML part and then maybe HttpClient for the things you normally will do in a browser. But there will be quite som work implementing this. There is nothing lightweight about SAML.
OpenSAML is just a library helping with processing of SAML messages so it is probably good for very customised stuff like this.
After some research, I ended up building it on my own.
I carefully followed every redirect, and took note of every cookie created, edited or deleted (Opera, with its in-built option which allows to switch off redirects was the key).
The result was a flow which then I replicated in a package ad hoc: the SetUpConnection class, whose task was connecting to the host and keeping track of the cookies. SAML class, which replicated the SAML flow, and finally the Main class, from which I can gather useful information.
Hope it helps.
I have a website that sends dynamic information to users via servlets. It is stateless and there are no logins. This specific site uses a decent amount of doPost() and doGet() calls from client browser to server.
My question is, if someone reads my source, they can easily just rip out my public facing servlet URL's and have a free API at my web servers expense.
How can I keep this from happening? Is there some kind of authentication package I can use between JavaScript and Java that doesn't add noticeable delays? I would only like users on my webpage to be able to call the public facing servlets.
Not an expert but this may help : http://oauth.net/ as I know big web API's like twitter use this.
Two ideas:
REFERRER HTTP header to make sure the client is coming from an
authorized source
require authorized users of your service to provide an API key tied to their website.
I want to create little Java application which can interact with secured website.
We have Railway site (https://irctc.co.in)
I want to create a console application from which I can send the usename and password to site as web post method and the result can be converted into console format.
Instead of opening the site in web browser, i would like to make it simpler using console window by avoiding other web elements and ads etc..
is it possible to do in Java? Please guide me.
I see two ways to do that. The first one is to implement java app based on top of HTTP request-respond engine. In this way you do not have to make any changes in your web-site but processing HTTP responds could be complicated due to design features. The second one is to create simple front-end service on Rails for special cases and interact with in your console app. For message format you can use JSON for example. This way IMHO is more suitable. Both way suggests use of HTTP libs stack, Apache has it there http://projects.apache.org/projects/commons_httpclient.html
first poster :)
As the title says, I am looking to create a desktop app which will notify me of changes on facebook and new emails, and the facebook part (the first part I've tried) is baffling me. I've never worked with an api before, and have no idea how to integrate facebook's api with this desktop helper I want to create. I will be using java to create this desktop helper.
Thanks in advance!
Here are few pointers for you to get started. Please feel free to ask for clarifications and I will edit my answer accordingly:
For facebook, you can actually pull all those info via their API. There are a lot of types for API, but Facebook specifically use REST API over http.
To simplify, think of it as making an http call with specific parameters and you will be getting an output back.
In order to use facebook API you need to understand their protocol including authentication/login and how to request for things that you want. This would require some reading to their documentation which is pretty complete and available at http://developers.facebook.com/docs/.
For the description of their API URL and the input/output documentation, you could directly jump to Graph API Documentation http://developers.facebook.com/docs/reference/api/.
In order to call their API via HTTP from Java, you could leverage HttpClient library from Apache Http Components project http://hc.apache.org/. They have plenty of tutorial and examples for how to make http call using HttpClient
For combining with all other emails accounts (per your question), you need to deal with SMTP or IMAP (whichever email protocol that you are planning to combine with Facebook). This is already built-in to Java via their Java Mail API collection
You then can poll this data on interval basis to get an update from Facebook and your mails
Once you have figured out how to get the data, the rest is just following a good MVC framework. That means separating out your presentation, data and controller (application logic). Make sure that you are separating the classes for #1 and #2 and each of them put their data to normalized data format that then get feed to your View (presentation layer)