tags:

views:

37

answers:

1

hi,

i want to maintain db cache(some keywords) in the servlet.when i am typing for 'a' i ahve 1000 keywords in Db which starts with 'a' and presently i am using js file to store all the keywords in cache.this is asome--. iwant to maintain the DB cache in servlet also and decrese the browser cache and next hitting keyword matches in the servlet Db , i want to reterive the top 10 keywords for the this hitting.

can you tell me how can i create the servlet cache.can yopu provide any pesudo code for that one....

thanks, Murali

+1  A: 

I can imagine you have a Servlet that accesses the Database in order to retrieve the top 10 keyboards based on the input delivered. That means whenever an A is pressed in the input field, you must use an XMLHttpRequest to call the servlet with that input.

The servlet should return you a list of keywords which you should parse and translate properly to your user again. (you could do this in multiple ways. An easy way is to just let the servlet respond with HTML for you,which you can set with Javascript in an element (innerHTML)).

As for caching, the servlet could use some cache and identify the requested input. You can build an own cache by generating a key from the input and the result of that input should be put into a Map.

You could also use an existing caching framework, like EHCache.

Stefan Hendriks
thanks for giving suggestion
murali