From VisualWorks®, 7.2 of October 20, 2003 on October 20, 2003 at 1:15:36 pm (Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned. Choose terminate or close.'] SubscribeServlet VisualWave VisualWave.HttpServlet false none filemutex Web Toolkit-Demos WebMailingList VisualWave.SubscribeServlet This is an example servlet that handles subscription requests. It is based on the servlet used at smalltalkchronicles.net. When it receives a request it adds a line to a file and sends mail to both the subscriber and the editor. Note that this won't work correctly without being reconfigured for a local smtp server and correct e-mail addresses. Instance Variables: filemutex <Semaphore> Mutual exclusion so that two people aren't writing to the subscribers file at the same time. VisualWave.SubscribeServlet servletness appendToFile: aString filemutex critical: [ | s | 'subscribers.txt' asFilename exists ifTrue: [ 'subscribers.txt' asFilename copyTo: 'subscribers.bak' asFilename]. s := 'subscribers.txt' asFilename appendStream. [s nextPutAll: aString; cr] ensure: [s close]]. doPost: aRequest response: aResponse | info | info := String new writeStream. aRequest getParameterNames do: [:each | info cr; nextPutAll: each; nextPut: $=; nextPutAll: (aRequest getParameter: each); cr.]. self appendToFile: '"', (aRequest getParameter: 'name'), '" ', (aRequest getParameter: 'email'). self sendSubject: 'subscription request' to: 'subscription@monitor.address' saying: info contents. self sendSubject: 'your subscription request' to: (aRequest getParameter: 'email') saying: 'Thank you for subscribing. Your request has been sent to the subscription department. If this was sent to you in error, please inform somebody'. aResponse redirectTo: '../subscribeworked.html'. sendSubject: subject to: recipient saying: body | mailer message | mailer := Net.SimpleSMTPClient host: 'some.valid.smtphost'. mailer username: 'sender@goes.here'. message := Net.MailMessage newTextPlain. message fieldValueAt: 'Mime-version' put: '1.0'. message text: body. message from: 'sender@goes.here'. message to: recipient. message subject: subject. mailer sendMessage: message. VisualWave.SubscribeServlet initialize initialize filemutex := Semaphore forMutualExclusion. "Imported Classes:" self error: 'Attempting to file-in parcel imports. Choose terminate or close' HttpServlet VisualWave Core.Object false none servletConfig Web Toolkit-Servlet Servlet