Servlet-Related Models

The models in the package freemarker.ext.servlet provide convenient models for adapting various interfaces from the Servlet API into TemplateHashModel instances. You can generate hashes for accessing attributes of a ServletContext, HttpSession, and HttpServletRequest, as well as for accessing the parameters of a HttpServletRequest. All objects these models contain are wrapped into template models using the bean wrappers (see "Models For Arbitrary Java Objects").

The freemarker.ext.servlet package also provides FreeMarkerServlet which is a convenient and fairly full-blown servlet that can be used as a view portion of a MVC system; that is, to render HTML output using FreeMarker templates. The servlet can load templates from an arbitrary directory, from the classpath, or relative to the web application directory. It is also easily tailored to special needs through subclassing. Please refer to the JavaDoc for detailed information on how you can use this servlet in your web application.

Integrating FreeMarker with JSP

Want to migrate to FreeMarker, but your corporate decision makers force you into using JSP? No problem. Look into the "jsp" web application inside the examples directory to see how can you embed FreeMarker templates into JSP pages. No joke.