...

View Full Version : Javascript - how to check if IE window exists with a specific URL!



yasar2002
09-12-2011, 03:03 PM
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

Rowsdower!
09-12-2011, 04:24 PM
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.

yasar2002
09-13-2011, 07:29 AM
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?



<%@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" );
}
%>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum