0

In web based application, I am using JSP and servlets. When user will access the application from his computer than user should aware that what connection he/she is using. How can i detect the user's internet connection type and show it on the page ?

Actually, I want to detect connection type i.e. whether user is using proxy or direct(using USB modem) internet.

Is there any possibility to check this using java-script ? If not then what are the possible ways to do this?

Blender
  • 289,723
  • 53
  • 439
  • 496
Ravi
  • 181
  • 1
  • 3
  • 12
  • check this answer http://stackoverflow.com/questions/2384167/check-if-internet-connection-exists-with-javascript – Suresh Atta Dec 26 '12 at 09:55

2 Answers2

0

I would be interested to know if there is a one but im sure javascript does not have enough previlleges to detect that

Hanky Panky
  • 46,730
  • 8
  • 72
  • 95
  • is it possible to detect the same in server-side using java and get it display in user's page ? – Ravi Dec 27 '12 at 07:04
0

You could try:

var online = navigator.onLine;

checkout the below lines :

var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;

function updateConnectionStatus() {
  alert("Connection bandwidth: " + connection.bandwidth + " MB/s");
  if (connection.metered) {
    alert("The connection is metered!");
  }
}

connection.addEventListener("change", updateConnectionStatus);
updateConnectionStatus();
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
  • will it work in case of web application in browser like ie, chrome or mozila ? – Ravi Dec 27 '12 at 07:02
  • 1
    it's working perfectly in mozilla in my code .you can check in onload function..by this line .. alert(""+navigator.onLine); – Suresh Atta Dec 27 '12 at 07:06
  • @suresh Thanks i also tested this but still my problem is to get connection type and show it user. Could you plz tell me how to achieve that ? – Ravi Dec 27 '12 at 11:00
  • check this link once https://developer.mozilla.org/en-US/docs/DOM/window.navigator.connection – Suresh Atta Dec 27 '12 at 11:29