Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Client-side javascript won't allow script access to other windows or tabs (unless those windows or tabs were directly created by the script in question - which I believe from your question is NOT the case here).

    That type of check would need to be done on the server side. I imagine you could do that pretty easily by IP address, if that helps.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #3
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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" );
       }
    %>


  •  

    Posting Permissions

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