velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Charles N. Harvey III" <charl...@alloy.com>
Subject RE: Is Template thread safe?
Date Wed, 03 Apr 2002 14:27:14 GMT
I have a question about errors related to this thread.
I would like to display the error in the .vm to the browser instead of just
to the log file.  I will have many developers working on many templates and
only the app guys will really have access to the logs.

So is there a way to display the error inline?  As in, instead of the
rendered
variable (or control statement) the error is displayed?  Or, can I pass all
errors to an error template like Jonah asked about and display the error
template?

I am imagining that I just need to know where the errors get handled in my
extension of VelocityServlet so I can catch them and put them into a context
and
then render the error template.

Thanks.

Charlie

> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Tuesday, April 02, 2002 8:37 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: Is Template thread safe?
>
>
> On 4/2/02 6:53 PM, "jonah benton" <jonah@jonah.com> wrote:
>
> >
> > Hi,
> >
> > I have a quick question- is Template thread safe?- stemming from a
> > slightly involved background problem.
> >
> > I have a servlet application in which I'd like to be able to send VTL
> > template-based responses when velocity-detected errors occur in normal
> > template processing. For instance, when velocity detects a syntax error
> > in the requested template, I'd like to load and send a special VTL page
> > that displays information about the error.
> >
>
> So far, so good.
>
> > While this two-layer scheme works well for developers, it requires two
> > layers of exception handling in the servlet to catch possible errors.
> > One layer catches exceptions thrown during normal request processing,
> > and one layer catches exceptions thrown during error page processing.
>
> Sort of - you can catch the syntax errors and not let them escape the
> 'handleRequest()' method (assuming you are using VelocityServlet...)
>
> > Yuck!
> >
> > The various encapsulation schemes I've considered all strike me as
> > involving too much complexity, except for one- loading and parsing the
> > error templates at initialization time. If I can keep parsed Template
> > instances as instance vars in the servlet, then merge those, I can keep
> > to one exception handling layer.
> >
> > Is Template designed to let me do this, or does the engine hand out
> > cloned instances of Template to different threads?
>
> Same instance.  Perfectly threadsafe.  That's actually what the
> caching does
> - it keeps one parsed copy and uses it for all requests.  The template
> itself is actually stateless - it's the context that you send
> through it at
> render time that can be modified...
>
> > Thanks, and as this is my first post, thanks to Geir for a great
> > technology.
>
> Thank you for the kind words, but there are many contributors to Velocity.
> I am just the noisiest... :)
>
> --
> Geir Magnusson Jr.                                     geirm@optonline.net
> System and Software Consulting
>
> The cost of synchronization is much less that the cost of stupidity.
>
>
> --
> To unsubscribe, e-mail:
> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:velocity-user-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message