www.webdeveloper.com
Results 1 to 3 of 3

Thread: Javascript - how to check if IE window exists with a specific URL!

Hybrid View

  1. #1
    Join Date
    Sep 2011
    Posts
    2

    Javascript - how to check if IE window exists with a specific URL!

    Hi All,

    I am not an expert in Javascript.

    Can I detect if 1 or more sessions of a website are open?

    for example, if a session with port 7005 is open like this one below, then I want to assign the next port to this user in the second window of browser

    http://90.97.8.0:7005/maximo/webclient/login/login.jsp

    the next IE window should appear like this:

    http://90.97.8.0:7006/maximo/webclient/login/login.jsp

    or
    http://90.97.8.0:7007/maximo/webclient/login/login.jsp

    Please advise.

    Thanks

    Yasar

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Use AJAX and make a "HEAD" request
    http://en.wikipedia.org/wiki/Ajax_%28programming%29

  3. #3
    Join Date
    Sep 2011
    Posts
    2

    Javascript - how to check if IE window exists with a specific URL!

    Thanks for inputs,

    I have a redirector application written in a JSP page.

    This contains an array that holds 4 URLs in the code mentioned below.

    100+ users access it to login to maximo.

    I want to make sure if 1 user launches two login sessions i.e., 2 IE windows, both of them should be different ports, otherwise system will not work.

    Can you put some more light on this and give some guideline what my approach should be?

    Code:
    <%@page import="java.net.HttpURLConnection"%>
    <%@page import="java.net.URL"%>
    
    
    <%
    
       String[] maxServer = { "90.97.8.0:7005/maximo", "90.97.8.0:7006/maximo" , "90.97.8.0:7007/maximo", "90.97.8.0:7008/maximo"};
       String Server = "";
       String errServer = "90.97.8.0:7001";
       
       String accessCount = (String) application.getAttribute("accessCount");
       if (accessCount == null) {
          accessCount = "0";
       }
    
       int i = Integer.parseInt(accessCount);;
       int sIndex = 0;
       String path ="";
       int counter=0;
       boolean error=false;
       while(counter < maxServer.length){
          try {
             sIndex = i % (maxServer.length );
             Server = maxServer[sIndex];
             path = "http://" + Server + "/webclient/login/login.jsp";
             URL url = new URL(path);
             HttpURLConnection conn = (HttpURLConnection) url.openConnection();
             conn.setRequestMethod("POST");
             conn.setDoOutput(true);
             conn.setDoInput(true);
             conn.connect();
             conn.disconnect();
             conn=null;
             break;
          } catch (Exception e) {
             i++;
             if(counter==maxServer.length-1){
                error=true;
                break;
             }
             counter++;
          }
       }
       application.setAttribute("accessCount", String.valueOf(i + 1));   
       response.setStatus(301);
       response.setHeader( "Connection", "close" );
       
       if(!error){
          response.setHeader( "Location", "http://" + Server + "/webclient/login/login.jsp");
       } else {
          response.setHeader( "Location", "http://" + errServer + "/maximo/webclient/login/error.html" );
       }
    %>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles