Intercepting WebView - java

Let if web page is bound to WebView, then is it possible to capture
the data that user is entering in the data fields of the web page?
In other words my activity need to intercept and interpret what is happening in
webview.... Is it possible?

It sounds like you are trying to create malicious software. Would you please elaborate a bit on what you are trying to do?

Make the web page contain a submit-button, which activates Javascript, that accesses a JavaScript API that your application exposes. This way, you can make your web page communicate the data directly to your Android Java code.

Related

What should i use to create web services app?

As an application to get a job I need to make a web app. I'm only familiar with Java SE so here comes my concerns. I need to make web service where at the beginning there will be authentication window, then I need to show the JSON data (probably parse it and show) as table or as list with button near to choose one of the row from the table to get to the next page where there user can choose a materials and so on.
I have data in JSON on server I need to pull it from there, then I need to show data which looks like this /materialDetails?ID=x where x is ID (it's probably HTTP or URI). Should I use Java REST? If yes I need to create a site in XML and then put java data inside? There're only a few tutorials on the internet and I can't find any good(sometimes the problem is in server, sometimes with dependencies). I was looking for information also on youtube but except https://www.youtube.com/watch?v=X36Dud8cS4Y I cant find anything useful? Could someone explain me this to make it at least a lil bit easier? Or just lead me to pick a specific framework. Thanks in advance
You could create a Dynamic Web Project with Tomcat and a MySQL Database for starters. You could use RESTEasy to create a WebService that gets data from your Database.
I don't know what exactly is expected from you, but this might be a good start. "Making a web app" is a bit like saying "I need to develop a java program", it is a bit vague !
I don't know REST but I think your application can be implemented with this technologies: HTML and Servlets/JSPs.
I would write an authentication page in HTML (one form element with 2 inputs and a button) which would pass credentials to a Java Server Page or a Servlet (they're equivalent). There I would build the table (another HTML element) thus producing a new HTML page.
P.S.: you're using JSON as a format so there's no need to learn XML.

Detect page change Java spring

I have a java spring app. It has many views. I got my app started using a template, and I'm trying to understand how exactly it's working. Basically, i have a single index.html page, and many html files which are used as views with the url looking ilke 'mysite.com/#/view0' . I want my java code to be able to detect that a use has changed a url (or loaded a different view) without having my javascript code send a rest request to the server. is this possible? I haven't posted any code as I'm stumbling through my question here, but if there is any further clarification I can give, please let me know
If you're using javascript routing (Which I assume because you're using a hash in the url) then no. There's nothing for the server to natively 'detect' because anchors (#) don't make a server side request.

scrape website multiple pages using Web Client java

I am trying to scrape a website, using Web Client, i am able to get the data on the first page and parse it, but I do not know how to read the data on the second page, the website is calling a java script to navigate to the second page. Can anyone suggest me how do I get the data from the next pages?
Thanks in advance
The problem you're going to have is while you (a person) can read the JavaScript in the first page and see it is navigating to another page, having the computer do this is going to be hard.
If you could identify the block of code performing the navigation, you would then need to execute it in such a way that allowed your program to extract the URL. This again is going to be very specific to the structure of the JavaScript and would require a person to identify this.
In short, I think you're dead in the water with this one, though it serves as a good example of why the Unobtrusive JavaScript concept is so important.
This framework integrates HtmlUnit with its headless javascript enabled browser to fully support scriping multiple pages in the same WebClient session: https://github.com/subes/invesdwin-webproxy

How to generate different HTML based on the device that access the page?

I am using Java EE 6 with all the reference implementations and I wonder how you can generate different responses based on the device accessing the page? At the moment when I develop a JSF page I target browsers running on PC. However I want to generate another HTML structure (that is, using another JSF page) when the user browses the page with a smart phone.
Now you wonder, "Why doesn't you use CSS media queries?". Yes, I could but that will only give limited control over the layout. Could someone give me some hints to where and what to start reading about to do this?
I don't want to use Spring, I know they have something like this.
I don't want to use Spring, I know they have something like this.
Just reinvent it then (cough).
Let's look how they did it. According to the Spring Mobile documentation, cited below,
LiteDeviceResolver
The default DeviceResolver implementation is based on the "lite" detection algorithm implemented as part of the Wordpress Mobile Pack. This resolver only detects the presence of a mobile device and does not detect specific capabilities. No special configuration is required to enable this resolver, simply configure a default DeviceResolverHandlerInterceptor and it will be enabled for you.
it seems that they have ported this piece of PHP code to this piece of Java code. You could just do the same (be aware of license rules!). The most sensible place for this would be a servlet filter which would then send a redirect depending on the outcome of the detection.
I think you will need to look to the HTTP_USER_AGENT.
No experience with Java, but look to System.getEnv("HTTP_USER_AGENT").
It should return a string name for the user agent. You should find in the web lists of common user agents, so you can easily classify them as mobile or not mobile.
Inspect HTTP header
user-agent
you can retrieve this using Servlet API: http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getHeader%28java.lang.String%29

How do I get data from a web form?

As a pet project I want to build a program that translate from English to Hebrew.
The way I want to make the translation itself is using a web site called morfix.
In this site can enter an English word and after pressing the "תרגום" (translate) button
the translation is brought.
My first choice is to write this program in Java, and I tried using htmlunit, but it does not work beacuse i guess the site uses AJAX to bring the results.
In what languge can I implement the part that submit the web form?
How can I integrate Java with that other language?
Thanks.
You can also send your request without form submit: http://milon.morfix.co.il/?q=try
You need a http analyzer to check what's going on when that button is pressed (Try Live HTTp headers for firefox). Then you can use any language to make the web request.

Categories

Resources