bonjour a tous , bon alors déjà j'annonce , je suis débutant html , java et cie , donc mes connaissances et ma compréhension sont assez basse.
essayé d'être pas trop technique ou de bien expliqué si possible, merci

bref , voici mon probleme:

je possede une carte ethernet avec 8 relais qui comporte un petit serveur web , l'envoi de commande sur les pages du serveur web fait commuter les relais.

ca peut fonctionner en autonome : demo a cette addresse :DEMO


Pour des raisons particulière j'ai besoin d'héberger mes pages perso sur un serveur différent sur mon LAN

Voici la page héberger sur le serveur intégré (j'ai déja reduit le code pour prendre moins de place)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
</head>
<body>
 
<div id="loading" style="display:none">Error:<br />Connection to relay board was lost.</div>
 
<div id="display">
<input value="VOLET 1 ARRET" id="voyantarret" type="button" onClick="newAJAXCommand('preset.htm?led1=0&led2=0');">
<input value="VOLET 1 BAS" id="voyantbas" type="button" onClick="newAJAXCommand('preset.htm?led1=1&led2=0');">
<input value="VOLET 1 HAUT" id="voyanthaut" type="button" onClick="newAJAXCommand('preset.htm?led1=1&led2=1');">
<a id="voyantlumiere">ce texte change de couleur avec le XML status.xml</a>
<input value="LUMIERE 1 ON / OFF" type="button" onClick="newAJAXCommand('rlyfs.cgi?rlyf=4');">
<input value="LUMIERE 1 VARIATION" type="button" onclick="newAJAXCommand('leds.cgi?led=4');">
 
</div>
 
<script type="text/javascript">
<!--
 
		// Parses the xmlResponse from status.xml and updates the status box
function updateStatus(xmlData) {
	// Check if a timeout occurred
	if(!xmlData)
	{
		document.getElementById('display').style.display = 'none';
		document.getElementById('loading').style.display = 'inline';
		return;
	}
 
	// Make sure we're displaying the status display
	document.getElementById('loading').style.display = 'none';
	document.getElementById('display').style.display = 'inline';
 
 
	//recupere l'etat des relais dans le fichier xml
	{
		if((getXMLValue(xmlData, 'led0') == '0')&&(getXMLValue(xmlData, 'led1') == '0'))
			document.getElementById('voyantarret').style.color = '#009900';
		else
			document.getElementById('voyantarret').style.color = '#ff0000';
	}
	{
		if((getXMLValue(xmlData, 'led0') == '1')&&(getXMLValue(xmlData, 'led1') == '0'))
			document.getElementById('voyantbas').style.color = '#009900';
		else
			document.getElementById('voyantbas').style.color = '#ff0000';
	}
	{
		if((getXMLValue(xmlData, 'led0') == '1')&&(getXMLValue(xmlData, 'led1') == '1'))
			document.getElementById('voyanthaut').style.color = '#009900';
		else
			document.getElementById('voyanthaut').style.color = '#ff0000';
	}
	{
		if(getXMLValue(xmlData, 'led4') == '1')
			document.getElementById('voyantlumiere').style.color = '#009900';
		else
			document.getElementById('voyantlumiere').style.color = '#ff0000';
	}
 
}
setTimeout("newAJAXCommand('status.xml', updateStatus, true)",500);
 
 
 
 
 
 
 
 
/**
 * Determines when a request is considered "timed out"
 */
var timeOutMS = 9999; //ms
 
/**
 * Stores a queue of AJAX events to process
 */
var ajaxList = new Array();
 
/**
 * Initiates a new AJAX command
 *
 * @param   the url to access
 * @param   the document ID to fill, or a function to call with response XML (optional)
 * @param	true to repeat this call indefinitely (optional)
 * @param   a URL encoded string to be submitted as POST data (optional)
 */
function newAJAXCommand(url, container, repeat, data)
{
	// Set up our object
	var newAjax = new Object();
	var theTimer = new Date();
	newAjax.url = url;
	newAjax.container = container;
	newAjax.repeat = repeat;
	newAjax.ajaxReq = null;
 
	// Create and send the request
	if(window.XMLHttpRequest) {
        newAjax.ajaxReq = new XMLHttpRequest();
        newAjax.ajaxReq.open((data==null)?"GET":"POST", newAjax.url, true);
        newAjax.ajaxReq.send(data);
    // If we're using IE6 style (maybe 5.5 compatible too)
    } else if(window.ActiveXObject) {
        newAjax.ajaxReq = new ActiveXObject("Microsoft.XMLHTTP");
        if(newAjax.ajaxReq) {
            newAjax.ajaxReq.open((data==null)?"GET":"POST", newAjax.url, true);
            newAjax.ajaxReq.send(data);
        }
    }
 
    newAjax.lastCalled = theTimer.getTime();
 
    // Store in our array
    ajaxList.push(newAjax);
}
 
/**
 * Loops over all pending AJAX events to determine
 * if any action is required
 */
function pollAJAX() {
 
	var curAjax = new Object();
	var theTimer = new Date();
	var elapsed;
 
	// Read off the ajaxList objects one by one
	for(i = ajaxList.length; i > 0; i--)
	{
		curAjax = ajaxList.shift();
		if(!curAjax)
			continue;
		elapsed = theTimer.getTime() - curAjax.lastCalled;
 
		// If we suceeded
		if(curAjax.ajaxReq.readyState == 4 && curAjax.ajaxReq.status == 200) {
			// If it has a container, write the result
			if(typeof(curAjax.container) == 'function'){
				curAjax.container(curAjax.ajaxReq.responseXML.documentElement);
			} else if(typeof(curAjax.container) == 'string') {
				document.getElementById(curAjax.container).innerHTML = curAjax.ajaxReq.responseText;
			} // (otherwise do nothing for null values)
 
	    	curAjax.ajaxReq.abort();
	    	curAjax.ajaxReq = null;
 
			// If it's a repeatable request, then do so
			if(curAjax.repeat)
				newAJAXCommand(curAjax.url, curAjax.container, curAjax.repeat);
			continue;
		}
 
		// If we've waited over 1 second, then we timed out
		if(elapsed > timeOutMS) {
			// Invoke the user function with null input
			if(typeof(curAjax.container) == 'function'){
				curAjax.container(null);
			} else {
				// Alert the user
				alert("Command failed.\nConnection to relay board was lost.");
			}
 
	    	curAjax.ajaxReq.abort();
	    	curAjax.ajaxReq = null;
 
			// If it's a repeatable request, then do so
			if(curAjax.repeat)
				newAJAXCommand(curAjax.url, curAjax.container, curAjax.repeat);
			continue;
		}
 
		// Otherwise, just keep waiting
		ajaxList.push(curAjax);
	}
 
	// Call ourselves again in 10ms
	setTimeout("pollAJAX()",10);
 
}// End pollAjax
 
/**
 * Parses the xmlResponse returned by an XMLHTTPRequest object
 *
 * @param	the xmlData returned
 * @param	the field to search for
 */
function getXMLValue(xmlData, field) {
	try {
		if(xmlData.getElementsByTagName(field)[0].firstChild.nodeValue)
			return xmlData.getElementsByTagName(field)[0].firstChild.nodeValue;
		else
			return null;
	} catch(err) { return null; }
}
 
//kick off the AJAX Updater
setTimeout("pollAJAX()",500);
 
 
 
//-->
</script>
</body>
</html>
bon comme ca , ca marche super bien
par contre quand je l'herberge sur un serveur different de celui integré il faut évidemment changer les chemin pour pointer sur le bon serveur

et c'est la mon probleme , la recuperation du status.xml (qui se trouve dans la racine du serveur)

Voici la structure du fichier XML
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<response>
<led0>0</led0>
<led1>0</led1>
<led2>0</led2>
<led3>0</led3>
<led4>0</led4>
<led5>0</led5>
<led6>0</led6>
<led7>0</led7>
<btn0>up</btn0>
<btn1>up</btn1>
<btn2>up</btn2>
<btn3>up</btn3>
<an1>0</an1>
<an2>0</an2>
<time0>03:22:21</time0>
</response>
j'adapte les liens de cette façon :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
</head>
<body>
 
<div id="loading" style="display:none">Error:<br />Connection to relay board was lost.</div>
 
<div id="display">
<input value="VOLET 1 ARRET" id="voyantarret" type="button" onClick="newAJAXCommand('http://tfoutfou2.dyndns.org:50150/preset.htm?led1=0&led2=0');">
<input value="VOLET 1 BAS" id="voyantbas" type="button" onClick="newAJAXCommand('http://tfoutfou2.dyndns.org:50150/preset.htm?led1=1&led2=0');">
<input value="VOLET 1 HAUT" id="voyanthaut" type="button" onClick="newAJAXCommand('http://tfoutfou2.dyndns.org:50150/preset.htm?led1=1&led2=1');">
<a id="voyantlumiere">ce texte change de couleur avec le XML status.xml</a>
<input value="LUMIERE 1 ON / OFF" type="button" onClick="newAJAXCommand('http://tfoutfou2.dyndns.org:50150/rlyfs.cgi?rlyf=4');">
<input value="LUMIERE 1 VARIATION" type="button" onclick="newAJAXCommand('http://tfoutfou2.dyndns.org:50150/leds.cgi?led=4');">
 
</div>
 
<script type="text/javascript">
<!--
 
		// Parses the xmlResponse from status.xml and updates the status box
function updateStatus(xmlData) {
	// Check if a timeout occurred
	if(!xmlData)
	{
		document.getElementById('display').style.display = 'none';
		document.getElementById('loading').style.display = 'inline';
		return;
	}
 
	// Make sure we're displaying the status display
	document.getElementById('loading').style.display = 'none';
	document.getElementById('display').style.display = 'inline';
 
 
 
	//recupere l'etat des relais dans le fichier xml
	{
		if((getXMLValue(xmlData, 'led0') == '0')&&(getXMLValue(xmlData, 'led1') == '0'))
			document.getElementById('voyantarret').style.color = '#009900';
		else
			document.getElementById('voyantarret').style.color = '#ff0000';
	}
	{
		if((getXMLValue(xmlData, 'led0') == '1')&&(getXMLValue(xmlData, 'led1') == '0'))
			document.getElementById('voyantbas').style.color = '#009900';
		else
			document.getElementById('voyantbas').style.color = '#ff0000';
	}
	{
		if((getXMLValue(xmlData, 'led0') == '1')&&(getXMLValue(xmlData, 'led1') == '1'))
			document.getElementById('voyanthaut').style.color = '#009900';
		else
			document.getElementById('voyanthaut').style.color = '#ff0000';
	}
	{
		if(getXMLValue(xmlData, 'led4') == '1')
			document.getElementById('voyantlumiere').style.color = '#009900';
		else
			document.getElementById('voyantlumiere').style.color = '#ff0000';
	}
 
}
setTimeout("newAJAXCommand('http://tfoutfou2.dyndns.org:50150/status.xml', updateStatus, true)",500);
 
 
 
 
 
 
 
 
/**
 * Determines when a request is considered "timed out"
 */
var timeOutMS = 9999; //ms
 
/**
 * Stores a queue of AJAX events to process
 */
var ajaxList = new Array();
 
/**
 * Initiates a new AJAX command
 *
 * @param   the url to access
 * @param   the document ID to fill, or a function to call with response XML (optional)
 * @param	true to repeat this call indefinitely (optional)
 * @param   a URL encoded string to be submitted as POST data (optional)
 */
function newAJAXCommand(url, container, repeat, data)
{
	// Set up our object
	var newAjax = new Object();
	var theTimer = new Date();
	newAjax.url = url;
	newAjax.container = container;
	newAjax.repeat = repeat;
	newAjax.ajaxReq = null;
 
	// Create and send the request
	if(window.XMLHttpRequest) {
        newAjax.ajaxReq = new XMLHttpRequest();
        newAjax.ajaxReq.open((data==null)?"GET":"POST", newAjax.url, true);
        newAjax.ajaxReq.send(data);
    // If we're using IE6 style (maybe 5.5 compatible too)
    } else if(window.ActiveXObject) {
        newAjax.ajaxReq = new ActiveXObject("Microsoft.XMLHTTP");
        if(newAjax.ajaxReq) {
            newAjax.ajaxReq.open((data==null)?"GET":"POST", newAjax.url, true);
            newAjax.ajaxReq.send(data);
        }
    }
 
    newAjax.lastCalled = theTimer.getTime();
 
    // Store in our array
    ajaxList.push(newAjax);
}
 
/**
 * Loops over all pending AJAX events to determine
 * if any action is required
 */
function pollAJAX() {
 
	var curAjax = new Object();
	var theTimer = new Date();
	var elapsed;
 
	// Read off the ajaxList objects one by one
	for(i = ajaxList.length; i > 0; i--)
	{
		curAjax = ajaxList.shift();
		if(!curAjax)
			continue;
		elapsed = theTimer.getTime() - curAjax.lastCalled;
 
		// If we suceeded
		if(curAjax.ajaxReq.readyState == 4 && curAjax.ajaxReq.status == 200) {
			// If it has a container, write the result
			if(typeof(curAjax.container) == 'function'){
				curAjax.container(curAjax.ajaxReq.responseXML.documentElement);
			} else if(typeof(curAjax.container) == 'string') {
				document.getElementById(curAjax.container).innerHTML = curAjax.ajaxReq.responseText;
			} // (otherwise do nothing for null values)
 
	    	curAjax.ajaxReq.abort();
	    	curAjax.ajaxReq = null;
 
			// If it's a repeatable request, then do so
			if(curAjax.repeat)
				newAJAXCommand(curAjax.url, curAjax.container, curAjax.repeat);
			continue;
		}
 
		// If we've waited over 1 second, then we timed out
		if(elapsed > timeOutMS) {
			// Invoke the user function with null input
			if(typeof(curAjax.container) == 'function'){
				curAjax.container(null);
			} else {
				// Alert the user
				alert("Command failed.\nConnection to relay board was lost.");
			}
 
	    	curAjax.ajaxReq.abort();
	    	curAjax.ajaxReq = null;
 
			// If it's a repeatable request, then do so
			if(curAjax.repeat)
				newAJAXCommand(curAjax.url, curAjax.container, curAjax.repeat);
			continue;
		}
 
		// Otherwise, just keep waiting
		ajaxList.push(curAjax);
	}
 
	// Call ourselves again in 10ms
	setTimeout("pollAJAX()",10);
 
}// End pollAjax
 
/**
 * Parses the xmlResponse returned by an XMLHTTPRequest object
 *
 * @param	the xmlData returned
 * @param	the field to search for
 */
function getXMLValue(xmlData, field) {
	try {
		if(xmlData.getElementsByTagName(field)[0].firstChild.nodeValue)
			return xmlData.getElementsByTagName(field)[0].firstChild.nodeValue;
		else
			return null;
	} catch(err) { return null; }
}
 
//kick off the AJAX Updater
setTimeout("pollAJAX()",500);
 
 
 
//-->
</script>
</body>
</html>
et donc en adaptant les liens de cette facon les commandes fonctionnent correctement , mais j'ai ce script qui s'execute a chaque fois "alert("Command failed.\nConnection to relay board was lost.");" , bien sur la solution n'est pas de le supprimer , et egalement je n'ai plus la mise a jour des status sur la page grâce au fichier XML , cela ne fonctionne plu
j'ai cherché pendant des heures , j'ai fait plusieurs essais et je n'y arrive toujours pas

Je suis persuadé que c'est très simple a comprendre pour des experts en java

En hébergeant le code de la dernière citation chez vous , vous devriez être capable de faire fonctionner la page comme si elle étais héberger sur un serveur de mon LAN
(j'ai mis les bon lien pour vous , moi en local , j'utilise l'adresse de ma carte qui est http://192.168.100.15:50150/ )

Un grand merci pour la future aide

J'apprécierai également de savoir pourquoi ca marche pas


MERCI