Austin Kottke's Code Site

Thoughts about Architecture – Java, C/C++, JS, Objective-C, Swift, Groovy, Grails, (RIP Flash)
Archive for the ‘velocity’ Category

I combined Stripes and Velocity into a J2EE filter that came out to be extremely useful, so I could have Stripes/JSPs and have Velocity rendering with every request. I love the toolbox.xml concept of velocity so I couldnt live without it, but wanted to use stripes for its amazing action controller functionality. Here is a filter which modifies the stripes response and then parses the response through the Velocity Template Engine. package; import; import; import; import; import java.util.Collection; import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import; import; import; import; import; import; import; import; import; import org.apache.velocity.VelocityContext; import; import; /******************************************************************************************** * * Our basic filter, all it does is take our WebSessionBean which is a wrapper around * the current session and passes it in the request, so that all jsps and other objects * can access the data, such as the current users shopping cart, his user info, and * other pertinent details to the session for this user. * * In addition to basic session addition, we also take the content and * add in the velocity template engine so the session can be accessed from * velocity, and all content, after stripes is done with it is modified * with velocity. * * We perform the following steps: * ——————————- * *…