/    Sign up×
Community /Pin to ProfileBookmark

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

[url]http://90.97.8.0:7005/maximo/webclient/login/login.jsp[/url]

the next IE window should appear like this:

[url]http://90.97.8.0:7006/maximo/webclient/login/login.jsp[/url]

or
[url]http://90.97.8.0:7007/maximo/webclient/login/login.jsp[/url]

Please advise.

Thanks

Yasar

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorSep 12.2011 — Use AJAX and make a "HEAD" request

http://en.wikipedia.org/wiki/Ajax_%28programming%29
Copy linkTweet thisAlerts:
@yasar2002authorSep 13.2011 — 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" );
}
%>
[/CODE]
×

Success!

Help @yasar2002 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.12,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...