[plt-scheme] best servlet development approach?
On Sat, May 17, 2003, Jon Buffington wrote:
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> After reading the documentation for the web-server collection
...
> what is the best approach for testing servlets in DrScheme?
I don't have any advice about testing per se, but I too just started
using servlets, and here are some things I wish I had known early on.
First: Be sure to run web-server from a console in order to see stdout
and stderr. I use Debian, and my early debugging attempts were
painful because the Debian PLT package includes an
/etc/init.d/mzscheme file that launches web-server with no console
output. It's a big advantage to be able to use stdout and stderr
normally for debugging.
Second: You can run web-server from either mzscheme or drscheme, eg
drscheme|mzscheme -qmvL launch.ss web-server. I've not figured out
how to start web-server from within drscheme for debugging and
profiling yet though.
Third: The XML module will choke on the empty list or "incorrectly"
nested lists. Until recently I was using Oleg's SSAX XML
representation which is very accomodating. It does the right thing
with eg '((p "hello")) '() and I think the unspecified value. It uses
(@) to specify an attribute list, whereas PLT uses a list only. PLT's
way is arguably better in that it forces the programmer to be less
sloppy, but on the other hand I don't know how to handle some
situations with PLT, for instance
`(html (head) (body ,(if condition '(h1 "Page Title")))) because
if 'condition' is false, then the XML parser will choke on the
unspecified value. There are a couple of workarounds that I know of,
neither very satisfactory.
Fourth and most important: don't judge web-server by the example
servlets. I was unimpressed by the examples at first glance and as a
result worked on a competing system for at least six months. I had
already written a continuation-handling system, and when I saw add.ss
I realized my system did that too, so why switch. Specifically I'm
talking about the scenario where you start writing out a page, and
midway through follow a continuation to create a different page that
prompts the user for information that you use subsequently in the
original page. What I missed at the time is that web-server provides
a way to preserve state between *every* page traversal. For instance
I no longer have a hashtable for storing a user's database
connections; I simply use a variable.
Hope this is helpful.
--Don