Description of Examples

There are six working examples in the 1.0b3 release of PluggableWebServer.


This is an extremely simple example to demonstrate embedded Smalltalk:

<html><title>Sample Embedded Page</title>
<p>Today is <?Date today printString?>
<p>Now is <?Time now printString?>


Factorial.html is Tim Jones' Webtalk Factorial Calculator done as a single page. Doing this one taught me to check that request fields are nil (meaning that we're at the initial visit to the page, before any forms input has occurred). I also learned that browsers will allow you to access an HTML page as an action, which I hadn't been sure of.

<html><title>Factorial Calculator</title>
<form method="POST" action="factorial.html">
<p><b>Number to compute:</b>
<input type=text name="number" value="<?request fields notNil ifTrue: [request fields at: 'number' ifAbsent: ['0']] ifFalse: ['0']?>" size=10 maxlength=10>
<p><input type=submit name="action" value="Compute Factorial">
<?request fields notNil ifTrue: [(request fields at: 'number' ifAbsent: ['0']) asNumber factorial] ifFalse: ['nothing yet']?>


proxy.html fetches a Web page for you. I did this because I'm about to go on a trip, and when I use my ISP via the 800 number that they provide, the DNS gets all screwed up. I can reach my server, but I often can't reach other pages that I use alot (like CNN,, etc.) This way, I can get the text at least.

Basically, this checks to see if there are any incoming fields, and if so, returns the contents of the page at the given URL. If no incoming fields, put up a form asking for a URL.

<? request fields notNil ifTrue: [(HTTPSocket httpGet: (request fields at: 'url')) contents] ifFalse: ['<html><title>Simple Proxy</title> <body> <form method="POST" action="proxy.html"> <p><b>URL to fetch:</b> <input type=text name="url" value="" size=80> <p><input type=submit name="action" value="Fetch"> </form> </body> </html>']?>


To install, ScreenshotAction setUp. Returns a GIF of the current server display (Squeak-only).

Web Chat

There's another example in the Server directory: chat.html. Chat talks to the ChatPage ServerAction, which accepts new notes, keeps track of the last 20 notes, then returns them when requested. The chat.html page also contains a meta directive to refresh the page every two minutes (configurable by the user). Just open the page and start chatting.

Web Workspace

I tested user authentication by creating a Workspace on the Web and having an immediate need to hide it! embedded/workspace.html gives you a space to type in some code (local variable declarations seem to work, too). Then hit the "Do it" button. The result is printed in the bottom text area. I just concatenate the latest result onto the top, so that you can have several results to look back on (sort of like a Transcript).


I build systems that feature "anchored collaboration" (like CaMILE), which means that I hang a collaboration space off of a normal HTML page that serves as an "anchor" -- something to talk about. Single click, make your comment. As a test of PWS, I wanted to see how quickly I could build an anchored collaboration space with the tool. The end result was not the best example of clarity and well-designed use, but it only took me one hour (and five minutes), which contrasts well with the three days for the last version of CaMILE. I re-did the Comment example for 1.0b2.

To try it, go to "pws.html" using your PWS server. You'll see a link for a discussion space on PWS. Click on it. You're now in a space where you see listed notes posted on the topic (none to start with) and a space for creating new notes.

Comment builds on two problem-domain classes: Note which keeps track of user notes, and Discussion which has some header information and a collection of notes. Comment is accessed via one of two URLs.

  1. "Comment.anything" (e.g., "Comment.assignment1" or "Comment.myHomePage") opens the discussion page for the "anything" topic. If the topic hasn't been created, a blank one will be created. A discussion page lists the notes on this page at the top, and provides a form for specifying a new comment at the bottom.
  2. "Comment.anything.n" (e.g., "Comment.assignment1.1") opens the nth note in the discussion.

The actual formatting of Comment spaces and notes is done through the web pages ShowNote.html and ShowComment.html. The HTMLformatter is handed these with a Note or Discussion object for formatting and display.

New in 1.0b3: One addition to the Comment page is the saveTo:/readIn: methods which let you save and restore the Comments table. By executing the line:

PWS addToBackupJob: [Comment saveTo: 'Comment']
I get hourly backups (separate from the Image) of all the Comments. Nice insurance, and useful when upgrading the system.

I'm actually using this system as a Comment space for a website (, so it continues to get enhanced.


SWiki is Simple Wiki or Squeak Wiki, or if you really insist, Stupid Wiki. It's based heavily on Ward Cunningham's wonderful tool, the Wiki Server (visit the Squeak Wiki at Wiki, and Swiki, are collaboratively-developed Web sites. You can edit anyone's page, and you can add new pages. There is a search capability. It's really simple, but amazingly powerful. For the time-being, I'm hosting one at

I tried running the version of Wiki at, but my students and colleagues here didn't like it. Part of it was that Perl's DBM is awful on our SunOS server, but a bigger part of it was that they didn't like all the rules for formatting. While they seem intuitive to me, most students in our University already know HTML, so they didn't like another language getting in the way. So, we used simpler rules for formatting:

Also, as in Ward's newer Wiki's, at the bottom of each page is a link to display the page and all of its references. This is nice for collaborative writing. If you have an outline on one page with links to all the sections, click on that one link, and you get a single page with everything folded in to a single page.

To create a SWiki in PWS, simply execute "SwikiAction setUp" This will create a Swiki named "myswiki". Access it via "http://yourserver/myswiki". Edit 'page.html' in the Swiki folder (in the Server folder) to create the look you want (e.g., you probably don't want the EduTech logo across the top of all of your Swiki's :-)

You can actually create new swiki's really easily. Simply create a folder in your Server folder with the name you want ("myclass"), then execute SwikiAction setUp: (e.g., "SwikiAction setUp: 'myclass'").

There are three classes and a set of files in the "swiki" folder that make Swiki work.

I recently gave directions on how to create a Swiki. These may be different enough to make more sense if the above doesn't.

- Create yourself a directory with the name you want in the Server folder,
e.g., "humor"
- Now, in the workspace, type "SwikiAction setUp: 'humor'" and do it.
- Done!  Now, if you want extra security (double saving of everything),
also create a backup action:
PWS addToBackupJobs: [(PWS actions at: 'humor') saveTo: 'humor.backup']
That will save the URLmap (key data structure) once an hour to
humor.backup.  If something terrible happens and the image becomes trashed:
SwikiAction restore: 'humor' from: 'humor.backup' (syntax may be wrong)
will do it.


"More About Squeak..."
Home Page for How To Squeak

Last modified at 1/30/98; 9:58:48 AM
Other Links of Interest
College of Computing | EduTech Institute | GVU Center
Mark Guzdial | CS2390, Modeling and Design | STABLE