Save user details from javascript into java - java

This is my situation:
I have a website stored in my mobile, I'm using "kws" to make my mobile as server, ofcourse when i turn on the hotspot in the mobile.
When an user will connect to my hotspot he will type unique ip and port and then enter to my website.
In my website there is place to leave details (email,phone number, name, etc..).
I actually want to take this details and send it to the java android program that is manages the website (i built android app to this mobile that manage the site, she switch the hotspot on/off ,etc..).
In the java code I want to get the details and write them to file or write them to my sqlite database in order to send it to specific email when i will be able to connect to the internet (when i connect to internet i turn off hotspot and the site isn't active anymore.)
The browsers it needs to support are: Internet Explorer, Chrome, Firefox.
How can i do it? don't forgett that the only connection i have is the hotspot in the mobile.

OK, so to solve that i used Websockets. Now i can pass data from javascript to java.
I used this: Writing a WebSocket Server.

Related

How to get and set values from a UPS device using SNMP?

I have a java web application running in my workplace.
I was asked to create a new application to "communicate" with network devices and read their statuses.
As an example I started working with a UPS, which is connected to my network with its own Network Interface Card.
I can monitor its status and details with its built-on platform entering with its IP address on a browser. But the idea is to add some of these details to the original web application.
To my understanding I can use a SNMP library for Java and create an application to get and set values to it. In my case i'm using the SNMP4j(V3) library, I imported it to Eclipse (IDE), but have no idea on how to continue from there really.

Q: How does wifi AP providers (e.g Starbucks,McD) pushes out "Sign In to surf website" notifications to customers, and how to implement that in JAVA?

I have 2 parts to my question. First is just a general question and second is more into app development and coding.
How does Starbucks/Coffee Bean/McDonalds pushes out notification whenever we as customers connect to their WIFI AP? They will push out notifications like "Sign In to proceed using the internet" in the status bar, and then redirects us to their website before we can start using the internet.
I am trying to create an app that does just that by creating a personal hotspot(that will have internet access), and whenever customers are logged into my hotspot, they will receive that same notification. My intention is to just direct them to a 'sign in' page in their browser, and once they click sign in, they will again be directed to my personal website. After that, they are free to surf any websites they want to.
So is it possible to do just that? I only want the app to be installed in my phone, and not in my customers phone.
I'm deducing a lot of this, but I don't see how else it could work.
The wifi hotspots you are referring to are themselves little web servers, in addition to being participants in the world wide web. When a browser sends a URL out, it eventually gets to a web server (we won't go into the DNS system here), and the web server -- a machine listening on one or two ports, ready to accept a URL via socket and return something in response -- responds to it.
In the case you're talking about, the little wifi web server stores the URL sent and, regardless of what it is, sends back the "login to continue" page, and ensures that it is responded to. Once it is, then it does its normal thing with the original URL, which in this case means it sends it out to the internet cloud for interpretation like a normal wifi hotspot would.
As future URLs are sent, the wifi hotspot ensures that the login has occurred -- perhaps it just uses the URL of the machine as a key to information about when it logged in last, or a cookie, there are a couple of ways -- and if there is a current login session, then it again passes the URL out to the internet cloud.
In order to do this in Java on your phone, you would need control of the socket input/output of the hotspot; you would have to be able to read the input, determine whether the login had occurred, and only then either pass along the incoming URL or store it so the login could take place. I don't know how you would do that.
What you describe is a "captive portal" - all new users connecting through the hotspot will have their HTTP requests redirected to this portal. Once you register, your IP-address is known and the redirect no longer occurs.
How this works on mobile devices is typically that when you connect to a hotspot your phone will try to access a well known address and when the redirection occurs to a HTTP-AUTH response it will then open the captive portal as part of the setup process. For instance in the case of the iPhone apple will try to access 'phobos.apple.com' which is why you'll often see this in the pop-up when you are trying to access a "other" website on an non-authenticated access point.
As regards doing this in Java, I think you will have a few problems on your hands. Typically Java only provides network access at TCP/UDP layers and above. Now what you could do is have your application acting as a "proxy" such that it relays all network activity through it, but this would be a heavy load for your application. It also would not have the transparency of the type of solutions you would be used to. Your users may also have to be told to access your site directly.
Your typical captive portal has a few different actors involved and a number of different protocols beneath the application layer. The Access Point needs to "know" whether a user is authorised or not (and thus is redirected to the portal, or gets to access the wider internet); The portal needs to be able to notify the portal upon authentication; 802.1x is used for the initial handshaking; DHCP to assign the IP-address based on MAC address.

How to send array to java (android) only with hotspot connection?

first off all sorry about the non-smooth english.
I have a problem with get data from user to my database or to string in my android java code.
I created website until now and i'm using my mobile as server.
In order to connect this site i turn the hotspot on and from a pc or other device i wrote the ip address with the port in the browser's address bar. for example, 192.160.42.1:8081.
My problem is that i have contact form in the site and i need the user will fill his details then i will get it in the android code (when he clicks send).
So can the user in the web click "send" and i will have a script that creates a new record in my Sqlite database? It will work for IE,Chrome,FireFox,Safary and android tablets browser? or i can pass string with his details from the contact form? (from the javascript to the java).
Notice that i dont have internet connection except the hotspot.
Bit unsure at what you are asking but if you just want to store the data locally then use an sqlite database from within your application, if you want to send data to an external website then in your code check for a internet connection and send a json string to your website and let a script there handle whatever you want to do with the data. If you dont have an internet connection then you could store the data in a sqlite database and send it when there is an connection.

How to prevent restrict access to a web application to authorized devices only?

I have developed an MVC web app. Right now, the client using this app in office area. The client has requested that no one should use this app on any device except the office's PC/tablets.
Now problem is, it's a web app, so how can I put restrictions that nobody can use this app from the outside of the office or with devices other with than office's PC/Tablets?
The usual approach to that problem is maintain a database of authorized MAC addresses. The next part is harder, because Java provides no mechanism to get the remote mac address. See this question. Given that I would require users authenticate to the web application, if an authorized user is on the device you could consider that device authorized. If that doesn't work, you might be able to use white-listed IP address ranges. If that doesn't work I think you're back to MAC addresses.

Connect from java mobile application to webservice to read messages

I have a website where users can send personal messages between them, now I want them to recieve the messages also on their mobile phone but without having to send them a SMS.
I am thinking about providing them with a mobile phone with internet access over GPRS or 3G, then develop a Java application that will connect to the website and retrieve the messages.
On the website I am thinking to make a webservice where the phone will login, get new messages, and also be able to answer back to messages.
Does anyone know any mobile application tutorial that will do that? Or do you recommend me where to start? I never done a java mobile application before, I only work with websites and PHP.
I also tried to use ICQ, the client is already done for java and for iphone, and I've also found a script that will send ICQ messages from PHP, but ICQ server bans you for 20 minutes when you do many reconnections, so I have to develop some kind of ICQ bot always online that will check for new messages to send from the mySQL database and then send them, one per 2-3 seconds, so the server won't ban me for flooding.
Well any advice or recommendation is welcome about how to have users connected to the website messaging system from their phones.
Thank you!
Instead of a Java Application, I would do a mobile HTML web page for the mobile devices because it will be simpler to deploy. I know Java is supposed to be WRITE ONCE RUN ANYWHERE, but with JavaME is not that simple. You will have to create special deployments for different phones, and there are phones that do not support JavaME (iPhone) at all.
With a mobile WEB SITE, the only thing your mobile phone needs is a browser. Pretty much every feature/smart phone have a browser these days.
If you insist on developing a JavaME application, you are on the right track. You can publish some WebServices on your WebSite and consume them from JavaME. Here is a tutorial on how to do that.

Categories

Resources