You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Chitraang Salvi <ch...@patni.com> on 2002/02/04 15:04:59 UTC
Problem with Storing Data in VelocityContext
Hi,
I have been working with Velocity Templates with Servlets (VelocityServlets)
to display a table of data. The table is actually displaying a set of rows.
This rows are the rows returned by executing a query. Now the Results
retrieved by the query are in the range of 200-300 so I am displaying the
results on a page wise basis. Something like 20 records on one page. Every
page which fetches more than 20 records will have a link saying "Next 20 of
total-count". On clicking Next the next set of records are retrieved.
The problem however is I have to make repeated database calls to retrieve
the whole reultset and then positionally fetch only 20 records. But this is
time consuming so I was wondering if I could somehow get the values from the
Context ( or some other method) rather than repeatedly making database
calls, the performance would improve drastically as the repeated database
calls (which are causing the performance drop) will be eliminated.
I tried to retrieve the context values by using get() method but it returns
null and inturn throws Exception. So can anyone suggest me a way out on this
as to how I can achieve this in Velocity.
My target is to avoid repeated database calls by storing the data somewhere
(preferably not in session) and then using it in Velocity for displaying the
same.
Thanking you in advance,
Best Regards,
Chitraang Salvi
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Problem with Storing Data in VelocityContext
Posted by Simon Christian <si...@cpd.co.uk>.
It seems that what you're talking about is precisely what the session is
for - do you have a strong reason for not wanting to use it?
If your database retrieves are complex, why not use a central caching
mechanism for your built objects/Hashmaps and simply store an array or
similar of references to those cached objects in the session.
You can then choose to either to all the work up front (building result
objects/maps for all results) or as and when your servlets make a
request to the cache.
- simon
Chitraang Salvi wrote:
> Hi,
>
> I have been working with Velocity Templates with Servlets (VelocityServlets)
> to display a table of data. The table is actually displaying a set of rows.
> This rows are the rows returned by executing a query. Now the Results
> retrieved by the query are in the range of 200-300 so I am displaying the
> results on a page wise basis. Something like 20 records on one page. Every
> page which fetches more than 20 records will have a link saying "Next 20 of
> total-count". On clicking Next the next set of records are retrieved.
>
> The problem however is I have to make repeated database calls to retrieve
> the whole reultset and then positionally fetch only 20 records. But this is
> time consuming so I was wondering if I could somehow get the values from the
> Context ( or some other method) rather than repeatedly making database
> calls, the performance would improve drastically as the repeated database
> calls (which are causing the performance drop) will be eliminated.
>
> I tried to retrieve the context values by using get() method but it returns
> null and inturn throws Exception. So can anyone suggest me a way out on this
> as to how I can achieve this in Velocity.
>
> My target is to avoid repeated database calls by storing the data somewhere
> (preferably not in session) and then using it in Velocity for displaying the
> same.
>
> Thanking you in advance,
>
> Best Regards,
> Chitraang Salvi
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>