Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can I implement the Cache using Servlets?  RSS feed

 
Dhayakar Tulasi
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I implement the Cache using Servlets?
If yes then how to implement?
If it is No then Can I implement the cache from stand alone application for multiple table ?

please...... explain the cache
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dhayakar Tulasi wrote:please...... explain the cache

Actually, that's the question for you. What is it you mean by "the cache"? What is it you want to be caching?
 
Kesava Krishna
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tulasi,

You can enable cache for servlets by setting init params. Below is the sample. Try redefining it as per you requirement. Need to write the below snippet in web.xml.
When working with Servlet filters this is more useful.

<init-param>
<param-name>
Cache-Control</param-name>
<param-value>
max-age=3600</param-value>
</init-param>

Thanks,
Kesava
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kesava Krishna wrote:You can enable cache for servlets by setting init params. Below is the sample.

This snippet accomplishes nothing as is. Maybe it does if there's a filter or servlet that makes use of it, but not on its own.

As Bear's question is yet to be answered, it's not possible to give useful advice.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dhayakar Tulasi wrote:If it is No then Can I implement the cache from stand alone application for multiple table ?

If I understand this correctly, you are trying to data from multiple tables into the cache, which would be resource hogging.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, if this is about caching data from the DB for later access, then sometimes that makes sense, but more often than not, it doesn't. Are you having specific performance issues that this is trying to address? What is the reason you feel that caching the data in necessary?

If you don't have a good reason, you shouldn't do it. "Because I think it might help" isn't a good reason.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!