import freemarker.template.Configuration; import freemarker.template.Template; import freemarker.template.TemplateException; import java.io.IOException; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Forgot extends HttpServlet { private Configuration cfg; @Override public void init() { cfg = new Configuration(); cfg.setServletContextForTemplateLoading(getServletContext(), "WEB-INF/views"); } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); Map root = new HashMap(); Template t = cfg.getTemplate("forgot.xhtml"); try { t.process(root, out); } catch (TemplateException ex) { } finally { out.close(); } } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } }
Servlet Example with Freemarker
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment