Package freemarker.ext.jakarta.servlet
Class AllHttpScopesHashModel
java.lang.Object
freemarker.template.WrappingTemplateModel
freemarker.template.SimpleHash
freemarker.ext.jakarta.servlet.AllHttpScopesHashModel
- All Implemented Interfaces:
TemplateHashModel
,TemplateHashModelEx
,TemplateHashModelEx2
,TemplateModel
,Serializable
An extension of SimpleHash that looks up keys in the hash, then in the
request, session, and servlet context scopes. Makes "Application", "Session"
and "Request" keys largely obsolete, however we keep them for backward
compatibility (also, "Request" is required for proper operation of JSP
taglibs).
It is on purpose that we didn't override
keys
and values
methods. That way, only those variables assigned into the hash directly by a
subclass of FreemarkerServlet
that overrides
preTemplateProcess
) are discovered as "page" variables by the FM
JSP PageContext implementation.
Note that this is for the legacy "javax" Servlet/JSP API; for Jakarta (that is, in modern Servlet containers), use
freemarker.ext.jakarta.servlet.AllHttpScopesHashModel
instead (since 2.3.33).
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from interface freemarker.template.TemplateHashModelEx2
TemplateHashModelEx2.KeyValuePair, TemplateHashModelEx2.KeyValuePairIterator
-
Field Summary
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
-
Constructor Summary
ConstructorsConstructorDescriptionAllHttpScopesHashModel(ObjectWrapper objectWrapper, jakarta.servlet.ServletContext context, jakarta.servlet.http.HttpServletRequest request)
Creates a new instance of AllHttpScopesHashModel for handling a single HTTP servlet request. -
Method Summary
Modifier and TypeMethodDescriptionGets aTemplateModel
from the hash.void
putUnlistedModel(String key, TemplateModel model)
Stores a model in the hash so that it doesn't show up inkeys()
andvalues()
methods.Methods inherited from class freemarker.template.SimpleHash
containsKey, copyMap, isEmpty, keys, keyValuePairIterator, put, put, putAll, remove, size, synchronizedWrapper, toMap, toString, values
Methods inherited from class freemarker.template.WrappingTemplateModel
getDefaultObjectWrapper, getObjectWrapper, setDefaultObjectWrapper, setObjectWrapper, wrap
-
Constructor Details
-
AllHttpScopesHashModel
public AllHttpScopesHashModel(ObjectWrapper objectWrapper, jakarta.servlet.ServletContext context, jakarta.servlet.http.HttpServletRequest request)Creates a new instance of AllHttpScopesHashModel for handling a single HTTP servlet request.- Parameters:
objectWrapper
- the object wrapper to use; notnull
.context
- the servlet context of the web applicationrequest
- the HTTP servlet request being processed
-
-
Method Details
-
putUnlistedModel
Stores a model in the hash so that it doesn't show up inkeys()
andvalues()
methods. Used to put the Application, Session, Request, RequestParameters and JspTaglibs objects.- Parameters:
key
- the key under which the model is storedmodel
- the stored model
-
get
Description copied from interface:TemplateHashModel
Gets aTemplateModel
from the hash.- Specified by:
get
in interfaceTemplateHashModel
- Overrides:
get
in classSimpleHash
- Parameters:
key
- The name by which theTemplateModel
is identified in the template.- Returns:
- The
TemplateModel
referred to by the key, ornull
if not found. - Throws:
TemplateModelException
-