Tutorial - Opening an URI on the Phone

This short tutorial shows how to write a web page that opens an URI (e.g. browser URL) on the phone.
Sometimes it can be handy to continue reading a web page on the phone that you have started reading in your browser on your PC.
You will see that with PAW this is a relatively easy thing to do.

We will start by testing the code in the BeanShell Console.

To test the code copy it to the BeanShell Console BeanShell Console and press the Execute button.

When executing the code, a web browser will be started on the phone which opens the requested URL.

Now that we know, that the code is working, let us build a web page to make the input of the URL easier.

The web page is a standard HTML page with a form element that calls the page itself on submit.
The main task is to check the input parameter uri and if present call the code above together with that parameter.
The BeanShell code is surrounded by <bsh> </bsh> tags. To get the request parameter the method parameters.get("uri") is used. If the result is not equals to null the above code will be executed.

Copy the above HTML content to a file called tutorial_uri.html onto your /sdcard/paw/html folder and enter http://android-ip-address:8080/tutorial_uri.html into the address bar of your PC's web browser.
After entering an URL and pressing the submit button, the web page should be opened on your Android device.

Below video shows how this should look like...