How does Java interact with buttons on http webpage? - java

I have little knowledge about web programming, and I was looking through a lot of examples which gives alot of examples about writing on the webpage for web browser to see, but nothing about getting request when user presses a button the webpage.
For example, upon opening the server, it opens the port 80, then I want to go to web browser and type "localhost:80" to access the webpage made by the server client. The webpage has a button which when I click it, webpage changes to something else like "Clicked!".
Can someone show me an example code of this? Link to an example would be great as well.
Thank you very much.

I would recommend using something like Apache's HttpClient to imitate a button press, which is just an HTTP POST. And if you don't want to use a third-party library, the standard Java library already rolls its own.

Related

how can I make TV webapp using springboot with tizen?

I want to make a samsung smart tv app with tizen.
I've made an webpage using springboot.
I tried making the app using that webpage codes I made, but I've got to know Tizen doesn't support java but html, css,and javascript only.
So I used meta http-equip="refresh", and let index.html go to my webpage url,
but there were long loading time, and ugly ui for a waiting page..
also remote control's pointer was weird. (not focusing on a certain button, but there is a cursor)
is there no way to solve this problem?
I've tried to find a way but I couldn't. please help me...
It seems that you are making a redirect to your website (hosted in internet).
Maybe would be better starting reading the basic concepts about Samsung Smart TV apps here
If you try to open external content (hosted websites) into your app the TV will use its web browser to open it.

Posting/clicking buttons java

i have some basic knowledge of java (made little programs to help everyday life) Now the thing is i want to make a program that posts offers on a site every 2-3 minutes. I have never done anything with java related to the internet and web pages and even after browsing the internet i am clueless. How would i go about setting up a connection to a certain page click a certain button on that page and then fill in 3 boxes with information and post the offer?
Here is what i have to click:
Here is the form i have to fill in:
You have to learn a bit more about how HTML form works, but basically browser sends a POST request to the webserver with the values from the form.
Chrome's Developer Tools, Firefox's web developer toolbar has a functionality what can help you to discover what request is sent to the server when you post a single form. Of course you have to fill the values with your heart content
If you already know what content you want to send, you can post it relative easily, it is described well with examples in this StackOverflow answer https://stackoverflow.com/a/4206094/182474.
But I strongly recommend to discover how browsers works internally from the aspect of HTTP protocol, because it is a very useful knowledge if you want to develop tools that interacts with web APIs or simulate posting HTML forms.
You could use java.awt.Robot class and make all this thinks =)
you only need to write your manually action to the automated action =)
move mouse on text
write this...
tab
write this other..
tab press enter
wait N second
hope it helps! =)

Submit a review(data) through android app on a url

I want to add a functionality in my app which submits a review of a place on the place's google plus account ..
As you might be knowing the format of the google plus page ..
It has a button "Write a review" (Which is not a button but a clickable 'div')
On pressing this button , a dialogue appears which has a field to write review , It is here i want to actually write the review through the code and press the submit button .
Please help me through this ..
How to achieve this thing ??
Jsoup parses HTML. It does not execute JavaScript or emulate a browser, so there's no dialog box for it to interact with.
You could try using a browser's network monitor feature (part of their developer tools) to see what requests are made when the dialog box is submitted, then simulate those requests from your application. You could also see if there's a Google+ API for submitting reviews other than from the place's Google+ page. APIs are easier to use, robust against changes in the web page's HTML, and don't risk violating terms of service that prohibit automation. Finally, you could try a browser automation tool (commonly used for unit testing web pages); I don't know of any for Android but I'd be surprised if there aren't any.

How to like a page on fanpage on facebook without a mouse

BACKGROUND
I'm doing an interactive art project for school.
PROCESS
For this project the last step is to go to a facebook fanpage and like the facebook page.
ASSUMPTIONS
I'll be using Java to open up a browser and then go to the facebook page. However, I would like to use something like one line of script to like the facebook fanpage.
PROBLEM
Is there will be no mouse for this interaction.
SOLUTIONS
Is there a script I (or stackoverflow) can write that I may execute that will like a facebook page?
Or is there any other solution that you guys can think of?
TOOLS/LANG. BEING USED: ARDUINO/JAVA, HTML, JAVASCRIPT and CSS.
You could use a browser automation framework like Selenium to load the Facebook page and simulate clicking on the Like button, but you would have to log the correct user in first. Selenium has a Java interface you could use.
Alternatively, if you are having it run on a single machine you control, you might have luck with doing some sort of userscript (something like this one) for the Facebook site so that when they are on the correct page, it clicks the Like button automatically. Then all you would have to do is launch the page from Java in the correct browser, and the userscript would do the rest. Note: Userscripts work on Firefox with GreaseMonkey installed, and on Chrome/Chromium without any extensions.
Make an application on Facebook and use their api to interact with the page: Facebook API
Alternatively, use some javascript to like the page once you navigate to it

Google Web Toolkit auto refresh grid

I implementing an application that has a grid in it and everytime someone changes something on this grid it automaticaly updates the grid for others who has the grid opened (something like what the google docs does).
I tried implementing this using gwt-rpc sending a request every 2 seconds and if there is something new the application just send what has changed. But I had some bad results when uploaded to the GAE server.
So I decided to analyze the google docs implementation and a saw that it keeps a open connection for almost one minute and send some new information everytime someones changes something. I would like to know if it's possible to do something like this on GWT. I'm trying to do it now using the request factory but I think I'll face the same problems.
Any ideas?
Since you use GAE you might want to look at Channel API.
There is also gwt-gae-channel, which is a GWT wrapper around Channel API's javascript client.
You might check out what the GWT folks gave to say about using push technology with GWT

Categories