write

toc
<mm:write>

The write tag can be used to `export' context variables to something else. When you only specify what variable (with the `referid' or `value' attribute), then this tag writes to the page (therefore it is named `write'), unless it has a body, in which case the information is simply available to other tags in the body (like another write tag without attributes).

This is the behavior of `writer' tags, and this tag is the most basic version of that. Being a `writer' tag it also supports the `jspvar' attribute with which you can make a JSP variable available in the body.

In addition to this basic `writer' functionality, the `write' tag itself can also write context variables to other storage locations, like the session and in cookies.

see alsoimport
attributes
  • referid
    The key of the variable to get. If it is missing (and value is missing), then the parent Writer tag is written (if it exist).
  • value
    The value to write. In this you can use context variables with "$", the advantage of this attribute above the referid attribute is that you can combine variables and add some text of your own. The disadvantages relate to complexity and efficiency.
  • session

    You can also put things into the session with this. The value of this attribute becomes the key of the session variable.

    At some other point you can pick up the variable again with the import tag (so then the `externid' attribute of import corresponds to the `session' attribute of write).


    see: from attribute of import
  • cookie
    Writing things to cookie is also possible. Analogous to writing to the session.
  • request (since: MMBase-1.7.4)
    With this you can set an attribute on the current request. Analogous to writing to the session.
  • application (since: MMBase-1.7.4)
    With this you can set an attribute on the current `application'. Analogous to writing to the session.
writer attributes
writerreferrer attributes
contextwriter attributes
contextreferrer attributes
example 1
<!-- write the variable `hoi' to the page -->
<mm:write referid="hoi" />
example 2
<!-- Create a JSP-variable `greet' from context variable `hoi', write
     `greet' uppercased to the page -->
<mm:write referid="hoi" jspvar="greet"><%= greet.toUpperCase() %></mm:write>
example 3
<mm:write referid="a" session="abc" />
<mm:import id="b" externid="abc" from="session" />

<!-- would copy the value of `a' to `b'. -->