Sun Microsystems Laboratories Experimental Stuff Text Document
# Standard TCL procedures for transferring data between the
# TCL environment and the server context.

  # fetch a session properties table

  proc get_data {name} {
    global SessionId
    set data [java::call sunlabs.brazil.session.SessionManager getSession \
       $SessionId $name [java::call Class forName java.util.Properties]]
    set data [java::cast java.util.Properties $data]
  }

  # put a value into the session table

  proc put {table name value} {
    puts "<!-- putting $name, $value -->"
    $table put $name $value
  }

  # get a value out of the request properties

  proc get {name {default ""}} {
    global request
    [java::field $request props] getProperty $name $default
  }

  # Put a value into the request properties

  proc update {name {default ""}} {
    global request
    [java::field $request props] put $name $default
  }

  # extract a list of property names that match a glob pattern
  # match - which elements to extract (glob match)
  
  proc extract_properties {{glob *}} {
      global request
      set props [java::field $request props]
      set result ""
      set enum [$props propertyNames]
      while {[$enum hasMoreElements]} {
          set key [[$enum nextElement] toString]
          if {[string match $glob $key]} {
              lappend result $key
          }
      }
      return $result
  }

  # send an email to "to" via "host"
  # Mail will include all query parameters on form + "Extra" stuff

  proc mailTo {to} {
    set extra "header.url SessionID header.address header.user-agent"
    foreach var [lsort "[extract_properties query.*] $extra"] {
	set value [list [get $var]]
	regsub {[^.]*\.} $var {} var
	append body $var=$value\n
    }
    java::call sunlabs.brazil.handler.SMTPHandler smtp \
	    [get host] [get SMTPhost patan.sun.com] \
	    download@www.experimentalstuff.com \
	    $to $body [java::null]
  }
This page is: http://www.experimentalstuff.com/About_this_site/tclinit.txt
Last Modified: Thu, 13 Jun 2002 18:57:31 GMT
copyright (c) 2000-2007, Sun Microsystems