Re: freemarker w/ servlets -- access contextRoot
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Saturday, January 22, 2011, 7:10:04 PM, David Siefert wrote: > Cool. So should the community (includes myself) move the > freemarker.ext.servlet stuff into a separate project? I've already > had to modify the servlet to support an alternate template loader > class, so I think it would be a worthwhile contribution. If you want to improve freemarker.ext.servlet in a backward-compatible(!) way then it's usually better if you sign a CLA and do it in the FreeMarker "official" code-base, as then more people will benefit from it. But modifying something that's in freemarker.jar also comes with more responsibility, as breaking something there will affect a lot of users. As of moving freemarker.ext.servlet (and freemarker.ext.jsp, etc.) out of freemarker.jar into a project with its own release schedule, that won't happen because of backward compatibility. But of course anyone can "fork" freemarker.ext.servlet by renaming the package. Would that turn into something significantly better than freemarker.ext.servlet, I might as well mark freemarker.ext.servlet deprecated in favor of the forked project. BTW, why I don't like when frameworks use freemarker.ext.servlet (or anything similar) is that it's just a JSP Model-2 (http://freemarker.org/docs/pgui_misc_servlet.html#pgui_misc_servlet_model2) hack which should only be used if a Web framework only supports Model-2. JSP Model-2 itself is already a dirty hack, so ext.servlet is a dirty hack for simulating another dirty hack. But an important point of FreeMarker (vs JSP) is exactly that you can just call it with a plain Java API, you don't have to forward a HTTP request and put information into HTTP request attributes and horrors like that. > Would it also be worth having the servlet automatically include in > the data-model some of the servlet request properties (just like > Request, Session, Application implicit objects get added)? It depends on the philosophy of the web application framework... (Like currently I'm working in one that doesn't even expose request attributes.) > Thanks, > David > > 2011/1/22 Daniel Dekany <[email protected]>: >> Saturday, January 22, 2011, 6:47:26 PM, David Siefert wrote: >> >>> Hi, >>> >>> I am wondering if there is any support for getting the contextRoot of >>> a web application in a freemarker template processed by the Freemarker >>> servlet? >> >> That can't be answered in general because FreeMarker has no dependency >> on Servlet-s or on HTTP at all; it just sees whatever was put into the >> data-model and generates text, and that's it. So what is available for >> the templates and how is completely up to the Web application >> framework authors. Sure, there is a freemarker.ext.servlet package, >> but that's just an extension (and I don't like that it's part of >> freemarker.jar) and many web frameworks use their own solution instead >> (and they should). >> >>> Thanks, >>> David >> >> -- >> Best regards, >> Daniel Dekany >> >> > > ------------------------------------------------------------------------------ > Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! > Finally, a world-class log management solution at an even better price-free! > Download using promo code Free_Logger_4_Dev2Dev. Offer expires > February 28th, so secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsight-sfd2d > _______________________________________________ > FreeMarker-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/freemarker-user > -- Best regards, Daniel Dekany ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d