Posts Tagged ‘AJAX’

Servlet Filter to prevent No-Cache

March 27th, 2011 No comments

In one of the posts, I had talked about IE caching AJAX calls. To solve this issue , you would have to modify response such that it informs browser not to cache the data coming from this server.

I am explaining it in plain old fashioned way of ServletFilter.

Below is the code for ServletFilter.

public class NoCacheFilter implements Filter {

private FilterConfig filterConfig = null;

public void init(FilterConfig filterConfig) {
this.filterConfig = filterConfig;

public void destroy() {
this.filterConfig = null;

* Modifies the response. Sets the appropriate headers
* and invoke the next filter in the chain:
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {

HttpServletResponse httpResponse = (HttpServletResponse) response;

httpResponse.setHeader(“Cache-Control”, “No-cache”);
httpResponse.setDateHeader(“Expires”, 0);
httpResponse.setHeader(“Pragma”, “No-cache”);
chain.doFilter(request, response);


This is helpful for browsers like IE which Cache your data by default and do not display fresh data. This is one of the situations when you are working with JSON REST web services in which you might to pull and display fresh data.

Categories: Uncategorized Tags:

Creating a dynamic tooltip with AJAX

April 10th, 2010 3 comments

The Tooltip is a common graphical user interface element. It is used in conjunction with a cursor, usually a mouse pointer. The User hovers the cursor over an item, without clicking it, and tooltip may appear – a small hoverbox with information about the being hovered over.

Ajax Tool tip : AJAX is the art of exchanging data with a server, and update parts of a web page – without reloading the whole page. By Using the Ajax tool tip we can show the content of the tooltip is retrieved by Ajax from external files.

  • Files to be used in the Ajax Tool tip
    • ajax-tooltip.html = Main HTML file
    • js/ajax-tooltip.js = Main JS file for the script
    • js/ajax.js = Ajax (SACK library)
    • js/ajax-dynamic-content.js = The dynamic content script from this site
    • css/ajax-tooltip.css = CSS for tooltip
    • images/arrow.gif = Arrow used in the tooltip
    • demo-pages = External files loaded by the tooltip

The files used for demo can be downloaded from here

Configuration : First, you need to include the js files and css files as in the demo (ajax-tooltip.html). Read more…

Categories: Uncategorized Tags:

ASP.NET 4.0 and AJAX Tutorial

January 27th, 2010 14 comments


AJAX, ‘Old wine in a new bottle’. Puzzled!  Absolutely right. AJAX was with us for a long time, until we realized its true potentials. Lets take a very close example and we use it in our everyday life. Google? Yes, very true. Google was very early mover in AJAX arena and showed the world, web applications close to desktop applications. People were so fascinated with desktop applications that there was an urgent need of such ‘Avatar’.  Suppose you are in the middle of filling a user registration page. You fill all the necessary information and hit the register button. says “Username already exists. Please try again”. You tried once, twice, thrice and so many times and after page refreshes it is showing the same message. Well, application does not have any choice but to display this error message. But now we can take off the pain and show something interactive, a user may like. Major websites will allow you to enter the username, but at the same time they will be able to tell you if this username has been taken out and without page refresh. That is AJAX. Most close example. Try typing words in Google search box and it will show you an array of suggestions. This is just a tip of iceberg. Believe me, you can create a very rich web based application by allowing AJAX to come into your life.

Topics We Will Cover

(1)    What is AJAX
(2)    Why to use AJAX
(3)    AJAX nomenclatures
(4)    AJAX with ASP.NET 4.0 (.NET 4.0 framework is still in beta but a lot to offer)
(5)    Future of AJAX  Read more…

Categories: Uncategorized Tags: