/
server.xml
170 lines (167 loc) · 6.47 KB
/
server.xml
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
<?xml version="1.0" encoding="UTF-8"?>
<CONTENT TITLE="Ajax and Server Communication" ID="ajaxRef">
<CONTENT TITLE="What is Ajax?" ID="ajax" NUMID="4_44">
<P>
<DFN TITLE="Asynchronous JavaScript and XML">Ajax</DFN>
is shorthand for Asynchronous JavaScript and XML. The technology is
based on the <ICODE>XMLHttpRequest</ICODE> Object. At its simplest,
it is the sending/retrieving of new data from the server without
changing or reloading the window location.
</P>
<MOREINFO>
Mozilla Documentation:
<URL>http://developer.mozilla.org/en/docs/XMLHttpRequest</URL>
MSDN Documention:
<URL>http://msdn.microsoft.com/en-us/library/ms535874%28VS.85%29.aspx</URL>
<URL>http://msdn.microsoft.com/en-us/library/ms759148%28VS.85%29.aspx</URL>
<DFN TITLE="Asynchronous JavaScript and XML">Ajax</DFN>
Libraries and Tutorial Sites:
<URL>http://jibbering.com/2002/4/httprequest.html</URL>
<URL>http://www.ajaxtoolbox.com/</URL>
</MOREINFO>
</CONTENT>
<CONTENT TITLE="How do I download a page to a variable?" ID="downloadPage" NUMID="4_38">
<P>
Although <ICODE>XMLHttpRequest</ICODE> can be used to download
entire pages, it is often used for downloading small pieces
of data that can be used to update the current page.
</P>
<MOREINFO>
<URL>http://jibbering.com/2002/4/httprequest.html</URL>
<URL>http://www.ajaxtoolbox.com/</URL>
</MOREINFO>
</CONTENT>
<CONTENT TITLE="How do I get a jsp/php variable into client-side javascript?"
ID="getServerVariable" NUMID="4_18">
<P>
Use a server-side language to generate the javascript.
</P>
<P>
Certain characters of ECMAScript strings must be escaped by backslash.
These include quote marks, backslash, and line terminators.
</P>
<P>JSP Example, using Apache Commons: <ICODE>org.apache.commons.lang.StringEscapeUtils</ICODE>:
</P>
<CODE>
var jsVar = "<%= StringEscapeUtils.escapeJavaScript(str) %>";
</CODE>
<P>PHP example using <ICODE>addcslashes</ICODE>: </P>
<CODE>
var jsVar = "<?php echo addcslashes($str,"\\\'\"\n\r"); ?>";
</CODE>
<MOREINFO>
<URL>example/addcslashes.php</URL>
<URL>http://php.net/manual/en/function.addcslashes.php</URL>
<URL>http://commons.apache.org/lang/</URL>
</MOREINFO>
</CONTENT>
<CONTENT TITLE="How do I log-out a user when they leave my site?"
ID="sessionExpired" NUMID="4_29">
<P>
This cannot be done reliably. Here's why:
</P>
<UL>
<LI>
The user may disable javascript so the log-out script will
never execute.
</LI>
<LI>
The user may not be on-line when they close your web page.
</LI>
<LI>
Javascript errors elsewhere in the page may prevent the script
executing.
</LI>
<LI>
The browser may not support the onunload event, or may not fire
it under certain circumstances, so the log-out function will
not execute.
</LI>
</UL>
The URL below has more information.
<MOREINFO>
<URL>http://groups.google.com/groups?selm=BlmZ7.55691%244x4.7344316%40news2-win.server.ntlworld.com</URL>
</MOREINFO>
</CONTENT>
<CONTENT TITLE="How do I run a server side script?" ID="runServerScript" NUMID="4_34">
<P>
You trigger a server-side script by sending an HTTP request.
This can be achieved by setting the <ICODE>src</ICODE> of an <ICODE>img</ICODE>,
<ICODE>Image</ICODE>, <ICODE>frame</ICODE>, or <ICODE>iframe</ICODE>, or by using <DFN
TITLE="XMLHttpRequest or XMLHTTP">XHR</DFN>, where supported.
</P>
<P>
An image will also
"swallow" the data sent back by the server, so that they will
not be visible anywhere.
</P>
<CODE>
var dummyImage = new Image();
dummyImage.src = "scriptURL.asp?param=" + varName;
</CODE>
<P>
Mozilla, Opera 7.6+, Safari 1.2+, and Windows IE 7
provide the <ICODE>XMLHttpRequest</ICODE> object
(Windows IE versions 5+, provides ActiveX to acheive an analagous
effect). <ICODE>XMLHttpRequest</ICODE> can send HTTP requests to
the server, and provides access the <ICODE>responseText</ICODE> or <ICODE>responseXML</ICODE>
(when the response is XML), and HTTP header information.
</P>
<MOREINFO>
<URL>http://jibbering.com/2002/4/httprequest.html</URL>
<URL>http://www.w3.org/TR/XMLHttpRequest/</URL>
<URL>http://developer.mozilla.org/en/XMLHttpRequest</URL>
<URL>http://msdn.microsoft.com/en-us/library/ms537505(VS.85).aspx</URL>
</MOREINFO>
<CONTENT TITLE="Why are my rollovers so slow?" ID="imageCache" NUMID="4_31">
<P>
Images are cached by the browser depending on the headers sent by
the server. If the server does not send sufficient information
for the browser to decide the image is cacheable, the browser
will check if the image has been updated every time you change the
src of an image (in some user settings). To overcome this you
must send suitable headers.
</P>
<MOREINFO>
<URL>http://www.mnot.net/cache_docs/</URL>
</MOREINFO>
</CONTENT>
</CONTENT>
<CONTENT TITLE="How do I force a reload from the server/prevent caching?"
ID="noCache" NUMID="4_17">
<P>
To reload a page, use <ICODE>location.reload()</ICODE>. However, this depends
upon the cache headers that your server sends. To change this,
you need to alter the server configuration. A quick fix on the
client is to change the page URI so that it contains a unique
element, such as the current time. For example:
<ICODE>location.replace(location.href+'?d='+new Date().valueOf())</ICODE>
If the <ICODE>location.href</ICODE> already contains a query String, use:
<ICODE>location.replace(location.href+'&d='+new Date().valueOf())</ICODE>
</P>
<MOREINFO>
<URL>http://www.mnot.net/cache_docs/</URL>
<URL>http://docs.sun.com/source/816-6408-10/date.htm</URL>
</MOREINFO>
</CONTENT>
<CONTENT
TITLE="Why is my Ajax page not updated properly when using an HTTP GET request in Internet Explorer?"
ID="ajaxCache" NUMID="4_45">
<P>
Browsers cache the results of HTTP requests to reduce network traffic.
To force the browser to request the document from the server, either
set the <ICODE>EXPIRES</ICODE> and/or <ICODE>CACHE-CONTROL</ICODE> response header(s)
with a past date or use a unique query string.
</P>
<CODE>
req.open("GET", "/example.jsp?date=" + (+new Date), true);
</CODE>
Always use the appropriate HTTP method. Do not use <ICODE>POST</ICODE>
to prevent caching. See <URL LINKTEXT="RFC 2616"
>http://www.faqs.org/rfcs/rfc2616.html</URL>.
<MOREINFO>
<URL>http://www.mnot.net/cache_docs/#EXPIRES</URL>
<URL>http://www.mnot.net/javascript/xmlhttprequest/cache.html </URL>
</MOREINFO>
</CONTENT>
</CONTENT>