Accessing a Java Web Application via Mobile - java

I have a basic web application written in Java, running on a tomcat on my localhost. Currently it's just a simple application with a single servlet to which I access from my browser.
I want to write a mobile android application which will be the client of my Java web application. I want the servlet to write to a DB and do some logic, but to access it from a mobile app.
Currently I don't have any domain registered.
How can I expose my Java web app so that in my development environment I would be able to access it via my mobile device? Meaning, currently it runs locally on my PC and I access from the browser (on localhost). I want to access it from a different device (mobile) - how can it be done in my home LAN?
Thanks.

If the web app is hosted on your local server, your mobile will need to be able to access the IP address (ie: 192.168.1.100) and port (ie: 8080) that is hosting the app.
There are several ways to allow your mobile to communicate to your desktop:
Direct connection via USB or Bluetooth.
Wireless connection on your LAN - if your mobile can connect
wirelessly to your home LAN, you should be able to access your web
app (your desktop's firewall may have to open up your web port)
External access. This requires opening up your home network to allow
access to your desktop's web port. Also your internet router would
have to be configured to allow access and likely do a NAT
translation. Note that in this scenario, anybody can access your web
app so be very careful. You would also need to use your external IP
address instead of your internal LAN address.
A domain is only required to allow the use of a name (http://www.example.com) instead of your IP address.

For testing, if your mobile device is on the same LAN as your server, just use the servers ip address on the LAN. Give the server a static ip address and your sorted.
For the next stage of testing, you'd need to expose your pc to access via the Internet. You'd usually do this by configuring your NAT settings on your home router. You should be able to google this.
Then your mobile device can use 3G and should talk to the server via your ISP ip address. This will hit your router and the NAT routing will forward it to your server machine on your LAN.
If you need any clarification, just ask !

Related

Add Java API to online server not localhost

I have just created a Hello World RESTful Java API with IntelliJ IDEA and Spring and I make several requests with http://localhost:8080/function and it works fine and return the JSON data well, but now I want to make request from my android app to get the same JSON data from another network. How to create global API or make my local API global or online?
If it is working on your PC, your next step is to host it somewhere which is reachable from the outside world. If it is still in testing mode, probably what you need to do is port-forwarding from your router, so that your requests to your public IP get forwarded to your PC.
In the long term of course you need to host it somewhere, unless you want to leave your PC running. You can buy a cheap hosting to start with on something like Digital Ocean, or go for the more advanced cloud service providers like Google and AWS.
in your router you have to redirect port 8080 to you network IP and allow port 8080 in your firewall
And use this IP address https://whatismyip.com.br/
You can create your java application in a container and deploy it on one of the cloud providers (AWS, Azure, Google App Engine).

How to connect to a server using an external ip (Java)?

I'm doing a project, I have a server, a client (C #), a client (Android java). I can connect to the server on the local network and use an external ip from the client C #, but from the Java client I can connect only by Wifi. The server on the router port forwarding, I have a static ip address. Help please what's the problem?
From the info you provided, there is nothing wrong.
For your C# client, you can connect it from local network (i assume 192.168.x.x)
and
For your java client, using wifi means local network (also i assumed 192.168.x.x)
so it means that it works well with local network.
So now the main problem is, is your server really online to internet
Please check the following:
Is your server accessible via any api testing tools, such as RESTFUL AND SOAPUI using external ip address.
Is you android client really online when not using a local network, or you can access it through external ip address.

How to "deploy" a server so that it can be reached over the internet?

I recently developed an Android application with which the Android device can communicate with another Android device running the application.
The communication works over sockets, therefore I developed a server which i run on my computer.
Here is my problem:
The communication between the devices over the Server running on my PC works fine, as long as all devices as well as the PC are in the same LAN (connected over the same Router for example).
Now I want to get the server online, so that the Android devices can connect to the "online" server and communicate with each other over the server from anywhere.
I simply have no idea of how to get the server online and running. How can I do that?
The main issue is, that I know about Client/Server communication locally, but have no experience in the "online" sector.
It is more a network problem than a programming one. Your server open a socket and therefore is available to anyone able to reach that socket.
You have to do a redirection on your router. The problem is that your machine doesn't have a public IP, only your router has one. So when your router receive a packet on port 21 for example, it doesn't know what to do with it. You have to configure it to say "the port 21 has to redirected to the local IP XXX"
Also the public IP of your modem/router can change, depending on your ISP. If your have a fixed IP, it won't change, otherwise you will have to install a software like dyndns to have a domain name associated with your IP.

Hosting a web service(Netbeans)

I have developed a web service using netbeans. It's currently being hosted locally(localhost). I wish to connect to this web service through my android phone(and not the emulator), however when using 3G, no connection takes place.
Is there a way that I could solve this? Thanks!
Local networks usually employ NAT. NAT prevents creating inbound connections, from internet to IPs inside NATed networks.
One way around this is to do port-forwarding on your router (if your router is the one doing the NAT).

Flex 4 iFrame open url internal network to an external network?

I need help with a question that I could not answer yet.
I have the following scenario:
One application Java EE / Flex 4 running on a tomcat, inside my Flex layer I have a iFrame passing a url to an ip of my internal network (http://192.168.1.195:8080/webvisu.htm) which is another application running within an industrial PLC.
When access this app from within my internal network works fine, but when I try to access this iFrame to an external network in my home for example have a timeout error on http://192.168.1.195:8080/webvisu.htm.
I believe this error occurs because the flex client is trying to run this url as I was in a internal network.
Is there any way to run this url from an external network?
Possible solutions:
Some setting on my Tomcat?
A crossdomain.xml file?
I've googled a lot about this problem, but found no solution = (
Sorry for my english I'm using the google translator
192.168.1.* is not a public IP address. The only way you'll be able to access it is if you have your home network connected to the other network over VPN; or if you have a web server set up on your local network which is running on the same IP address.
The use of domain names are supposed to address the problem of accessing IPs directly; but if you're accessing a non-publcly accessible app, you're kind of stuck.
On my current project, for example, the dev server uses an IP Address and the QA server uses a IP address. Neither of these apps are accessible outside the network. I have to connect via VPN to access them.
The production server; however; uses a domain name.

Categories

Resources