Resent.
ML server seems to silently ignore this mail
because of my from addr...
yuzo: Looking into your mail, overloading get_instance
is not recommended now?
-----Original Message-----
From: NAKAMURA, Hiroshi [mailto:nakahiro@sarion.co.jp]
Sent: Wednesday, July 10, 2002 4:25 PM
To: 'webricken@notwork.org'
Subject: Re: Persistant Servlets
Hi,
Bare in mind I've not tested it...
> From: Norman Makoto Su [mailto:normsu@slab.tnr.sharp.co.jp]
> Sent: Wednesday, July 10, 2002 11:43 AM
> In this example, "Count: 0" is printed each time the browser
> access the servlet,
> /hello.
>
> #!/usr/local/bin/ruby
> require 'webrick'
> include WEBrick
>
> s = HTTPServer.new( :Port => 2000 )
> class HelloServlet < HTTPServlet::AbstractServlet
# Overloads AbstractServlet#get_instance
# which creates new servant.
class << self
def get_instance(*arg)
self
end
end
> def initialize(server, *options)
> @i = 0
> end
>
> def do_GET(req, res)
> res.body = "<HTML>Count #{@i}</HTML>"
> res['Content-Type'] = "text/html"
> @i += 1
> end
> end
> s.mount("/hello", HelloServlet)
s.mount("/hello", HelloServlet.new)
> trap("INT"){ s.shutdown }
> s.start