------art_371_713421.1101573523022
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Here is some code I want to share.
Suggestions for improvements are welcome :-)


xmlhttprequest.rb

This is an example of how to use XMLHttpRequest.
Requires either Konqueror 3.3.1, Firefox 1.0 or better.

In order to start the servlet, type:
ruby xmlhttprequest.rb

In your browser you can goto:
http://localhost:10080/



iframe_reload.rb
his is an example of how to reload an <iframe>.
Requires either Konqueror 3.2.2, Firefox 1.0 or better.

In order to start the servlet, type:
ruby iframe_reload.rb

In your browser you can goto:
http://localhost:10080/




WEBrick is indeed wonderful. Thanks.

--
Simon Strandgaard

------art_371_713421.1101573523022
Content-Type: application/octet-stream; name="xmlhttprequest.rb"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="xmlhttprequest.rb"

cmVxdWlyZSAid2VicmljayIKCmNsYXNzIEluZGV4U2VydmxldCA8IFdFQnJpY2s6OkhUVFBTZXJ2
bGV0OjpBYnN0cmFjdFNlcnZsZXQKCWRlZiBkb19HRVQocmVxLCByZXMpCgkJcmVzLmJvZHkgPSA8
PEVPSFRNTAo8P3htbCB2ZXJzaW9uPSIxLjAiIGVuY29kaW5nPSJJU08tODg1OS0xIj8+CjwhRE9D
VFlQRSBodG1sIFBVQkxJQyAiLS8vVzNDLy9EVEQgWEhUTUwgMS4wIFN0cmljdC8vRU4iCiAgICAg
ICAgImh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXN0cmljdC5kdGQiPgo8
aHRtbCB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCIgeG1sOmxhbmc9ImVuIiBs
YW5nPSJlbiI+CjxoZWFkPgo8dGl0bGU+VGVzdDwvdGl0bGU+CjxzY3JpcHQgdHlwZT0idGV4dC9q
YXZhc2NyaXB0Ij4KZnVuY3Rpb24gYnV0dG9uX2dldCgpIHsKCXZhciByZXEgPSBuZXcgWE1MSHR0
cFJlcXVlc3QoKTsKCW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GVudC10eXBlJ10gPSAndGV4dC9odG1s
OyBjaGFyc2V0PWlzby04ODU5LTEnCgllbmQKZW5kCgppZiAkMCA9PSBfX0ZJTEVfXwoJcyA9IFdF
QnJpY2s6OkhUVFBTZXJ2ZXIubmV3KAoJCTpQb3J0ICAgICAgICAgPT4gMTAwODAsCgkJOkxvZ2dl
ciAgICAgICA9PiBXRUJyaWNrOjpMb2cubmV3KCRzdGRlcnIsIFdFQnJpY2s6OkxvZzo6REVCVUcp
LAoJCTpBY2Nlc3NMb2cgICAgPT4gWwoJCQlbICRzdGRlcnIsIFdFQnJpY2s6OkFjY2Vzc0xvZzo6
Q09NTU9OX0xPR19GT1JNQVQgIF0sCgkJCVsgJHN0ZGVyciwgV0VCcmljazo6QWNjZXNzTG9nOjpS
RUZFUkVSX0xPR19GT1JNQVQgXSwKCQkJWyAkc3RkZXJyLCBXRUJyaWNrOjpBY2Nlc3NMb2c6OkFH
RU5UX0xPR19GT1JNQVQgICBdLAoJCV0KCSkKCXMubW91bnQoIi8iLCBJbmRleFNlcnZsZXQpCglz
Lm1vdW50KCIvcGFnZS5jZ2kiLCBQYWdlU2VydmxldCkKCXRyYXAoOklOVCkgZG8gCgkJI2Zvcmt7
IHMuc2h1dGRvd24gfQoJCWV4aXQhIAoJZW5kCglzLnN0YXJ0CmVuZA------art_371_713421.1101573523022
Content-Type: application/octet-stream; name="iframe_reload.rb"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="iframe_reload.rb"

cmVxdWlyZSAid2VicmljayIKCmNsYXNzIEluZGV4U2VydmxldCA8IFdFQnJpY2s6OkhUVFBTZXJ2
bGV0OjpBYnN0cmFjdFNlcnZsZXQKCWRlZiBkb19HRVQocmVxLCByZXMpCgkJcmVzLmJvZHkgPSA8
PEVPSFRNTAo8P3htbCB2ZXJzaW9uPSIxLjAiIGVuY29kaW5nPSJJU08tODg1OS0xIj8+CjwhRE9D
VFlQRSBodG1sIFBVQkxJQyAiLS8vVzNDLy9EVEQgWEhU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