Re: [Simpleweb-Support] A complete tutorial?
Brought to you by:
niallg
|
From: Michael \Luni\ L. <lun...@ya...> - 2004-12-23 22:42:42
|
--- "Michael \"Luni\" Libes" <lun...@ya...> wrote: > Where's the rest of the tutorial? The enclosed source code is based on David Flanagan's efforts at a) getting Simple up and running, and b) serving both dynamic and static content from the same "Engine". 1. Throw this into the Simple/source tree 2. 'cd' to your Simple directory 3. run 'ant all' 4. run 'java -cp jar\simple-2.5.3.jar simple.sample.Application 8080 .' 5. Fire up a browser and go visit 'http://127.0.0.1:8080/'. This will run the simple.sample.HttpService code. 6. Visit 'http://127.0.0.1:8080/img.gif'. This will run the simple.sample.ImageService code (which will return a blank/invalid image). 7. Visit 'http://127.0.0.1:8080/file/build.xml'. This will load the build.xml file from the current directory. Note that the prefix '/file' is stripped off the request. This sample code skips the complexity of MapperEnginer and LoaderEngine, plus it hides the complexity of FileEngine. Intead, it creates a new subclass of ProtocolHandler which like LoaderEngine, uses simple.util.Resolver to match patterns with Services. Unlike the existing Simple Engine's, the Service classes are expected to be included within the application. If you need dynamically loaded Services, then add a MappingEngine into the RequestHandler like the FileEngine. Set the appropriate pattern (e.g. '*.class') for dynamically loaded classes, and you'll have a basic web server with a mix of files and 'CGI's'. Similar patterns can be added for template-based pages. And finally, note that RequestHandler includes the code from DemoServer in the existing tutorial. I still have no idea how that was supposed to be chained into the requests for HelloService. Niall, note that I've put your copyright header on the top of these files. They are yours to include in Simple and to improve as you see fit. Michael Libes |