Good points Kris, hope you don't mind, but I added your comments to the page I set up (although I slightly modified the whitespace *hack*).
http://www.niallp.pwp.blueyonder.co.uk/emailTemplate.html Niall ----- Original Message ----- From: "Kris Schneider" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[email protected]> Sent: Tuesday, January 25, 2005 4:32 PM Subject: Re: OT - Evaulating JSP as internal template? > For the paranoid, you probably want to be sure that the email template > ("EmailTestTemplate.jsp") doesn't actually produce any output. Because you're > doing an include followed by a forward, there's a *possibility* that the > forward will throw an IllegalStateException if the include causes the response > to be committed. You can use one of the various JSP whitespace "hacks" to > help: > > <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %><%-- > > --%><bean:define id="emailStuff" toScope="request"> > ... > </bean:define> > > Obviously, the example is unlikely to cause a problem, but a more involved page > might. > > Another approach might be to pass an HttpServletResponseWrapper to the include > method whose output stream (or writer) just buffers the entire response for > later retrieval. > > Quoting Niall Pemberton <[EMAIL PROTECTED]>: > > > You can do this easily using the <bean:define> tag and the > > RequestDispatcher. I've put a page up on my web site showing how: > > > > http://www.niallp.pwp.blueyonder.co.uk/emailTemplate.html > > > > I believe the RequestDispatcher is the "magic" JSP processor you're looking > > for. > > > > Niall > > > > ----- Original Message ----- > > From: "William Stranathan" <[EMAIL PROTECTED]> > > To: "Struts Users Mailing List" <[email protected]> > > Sent: Tuesday, January 25, 2005 11:00 AM > > Subject: OT - Evaulating JSP as internal template? > > > > > > > The subject is prolly a poor way to say what I'm trying to say.... > > > > > > Does anybody know of a simple way to use JSP as an INTERNAL templating > > > engine. For example, if I have a struts application where I'm > > > generating an email to send, I currently have to use Velocity on the > > > server side to put the values into the template, then send that. > > > > > > Is there a simple way to do the same with JSP? Would I be best served > > > by on the server side, constructing an HTTP request to a JSP that simply > > > pops in the request attributes into the correc place? > > > > > > High-level of what I want to do: > > > > > > ActionForward execute(mapping, form, request, response) { > > > MyForm myform = (MyForm)form; > > > > > > Hashtable vals = new Hashtable(); > > > vals.put("user",form.getUser()); > > > vals.put("car",form.getCar()); > > > > > > JSPProcessor proc = new JSPProcessor(); > > > proc.getRequestScope().put("values",vals); > > > StringBuffer buff = proc.evaluate("WEB-INF/templates/email.jsp"); > > > > > > MailUtils.mail("[EMAIL PROTECTED]",buff); > > > } > > > > > > Where JSPProcessor is the kind of magic I'm looking for. I don't really > > > see anything built into the API spec, so I SUSPECT if there were > > > anything available in Tomcat, for instance, it would be implementation > > > specific. > > > > > > Not a HUGE deal, but it's kinda' a pain to have to train new folks on > > > how to put together the JSP's AND how to put together the velocity > > > templates. > > > > > > Thanks, > > > Will > > -- > Kris Schneider <mailto:[EMAIL PROTECTED]> > D.O.Tech <http://www.dotech.com/> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

