James, On Mon, 9 Dec 2002 15:18:21 -0000, James Strachan said: >Thanks for the patch Kelvin, I've committed it to CVS. > >I made a minor patch so that the URI itself could denote the script >to run. >So you could just run http://localhost:8080/foo/index.jelly for >example, rather than requiring a template=index.jelly query >parameter..
That's nice. I have changed the parameter "template" to "script". Its just that I'm so used to using Velocity. The patch you made uses getServletPath, which returns the url of the servlet being called. I've changed it to getPathInfo. Another thing. Is it really appropriate to require all scripts to be located beneath the web app's context root (which getResource does)? The previous impl using new File(script).getUrl had no such limitation... > >Some thoughts for further improvement could be... > >* implement a JellyServletContext so that the getResource() method >will use the ServletContext.getResource() method and allow access of >relative URIs when performing <j:include>'s. done. > >* have a parent JellyServletContext to allow access to the >initParams of the ServletContext via variable expressions > ? >* implement the JSTL mappings of request parameters, session >parameters, cookies etc in the expression language. > >* it'd be nice to have a cache of Jelly Scripts to avoid parsing >them each time! :-) > Here's something which is a little surprise. So it means Jelly is not internally caching scripts? This has some implications for usage of Jelly as a templating subsystem for high-load systems, I imagine. In any event, perhaps it would be a better idea to cache at the engine level, rather than the servlet level, no? See attached for patch to JellyServlet and JellyServletContext. Regards, Kelvin -------- The book giving manifesto - http://how.to/sharethisbook
JellyServletContext.java
Description: Binary data
cvs -z9 diff JellyServlet.java (in directory C:\checkout\jakarta-commons-sandbox\jelly\src\java\org\apache\commons\jelly\servlet\) Index: JellyServlet.java =================================================================== RCS file: /home/cvspublic/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/servlet/JellyServlet.java,v retrieving revision 1.1 diff -r1.1 JellyServlet.java 2c2 < * $Header: /home/cvspublic/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/servlet/JellyServlet.java,v 1.1 2002/12/09 15:18:26 jstrachan Exp $ --- > * $Header: >/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/servlet/JellyServlet.java,v > 1.1 2002/12/09 15:18:26 jstrachan Exp $ 59c59 < * --- > * 65d64 < import java.io.File; 84,85c83,84 < * < * @author Kelvin Tan --- > * > * @author <a href="mailto:[EMAIL PROTECTED]">Kelvin Tan</a> 99c98 < protected void doGet( --- > protected void doGet( 103c102 < --- > 111c110 < --- > 124c123 < --- > 126d124 < URL template = getTemplate(req); 128c126,127 < runScript(template, context, req, res); --- > URL script = getScript(req); > runScript(script, context, req, res); 144,145c143,144 < < JellyContext ctx = new JellyContext(); --- > > JellyContext ctx = new JellyServletContext(getServletContext()); 151a151,158 > * <p> > * Either use the query parameter "script", or the URI itself > * to denote the script to run. > * </p> > * <p> > * Example: script=index.jelly or http://localhost:8080/foo/index.jelly. > * </p> > * 157c164 < protected URL getTemplate(HttpServletRequest req) --- > protected URL getScript(HttpServletRequest req) 159,162c166,169 < < String script = req.getParameter("template"); < if (script == null) { < script = req.getServletPath(); --- > > String scriptUrl = req.getParameter("script"); > if (scriptUrl == null) { > scriptUrl = req.getPathInfo(); 164c171,175 < return getServletContext().getResource(script); --- > URL url = getServletContext().getResource(scriptUrl); > if (url == null) { > throw new IllegalArgumentException("Invalid script url:" + scriptUrl); > } > return url; 183c194 < --- > 208c219 < --- > 213c224 < html.append("<h2>JellyServlet : Error processing the template</h2>"); --- > html.append("<h2>JellyServlet : Error processing the script</h2>");
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
