TCS-JPMC BLOG

© 2009 Tata Consultancy Services Limited. All Rights Reserved

  • March 2009
    M T W T F S S
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    3031  
  • Recent Posts

  • Archives

  • Top Clicks

    • None
  • Recent Comments

    Rohit on 03/26/2009

03/19/2009

Posted by tcsjpmc on March 27, 2009

Posted by Satyanarayana Guggilapu

Technical Tip of the Day

TIP 1::

AJAX caching issue::

Hope everyone knows what for AJAX is used. AJAX is used for making asynchronous calls to the server so that user does not feel that
the page is actually refreshed. The call will be made by using XMLHttpRequest object which is supported by most of the browsers. Its the browser which
actually makes the asynchronous call to the server. The AJAX request URL must be unique otherwise the brrowser does not make call to the server.
Instead it uses the previously cached response. For e.g say the AJAXURL is /requestPath?param1=value1. If you send the same URL second time,
browser does not make call again instead it gets the response from the previously cached one.

AJAX caching issue solution ::

1. AJAX URL must be made unique. We can make the URL unique by appending some unique parameter to the URL. For e.g we can generate a random number and
appends it to the URL. For e.g URL ‘/requestPath?param1=value1&justToMakeIEHappy=’+Math.random(). This always makes URL unique.
NOTE :: This issue happens only when we use HTTP GET requests for sending AJAX URL.

2. USE HTTP POST request.In this case URL need not be unique since browser does not check for unique URL in header as form parameters are sent in HTTP
body in case of POST requests.

Tip 2::

JAVA Collections
Ordering is one of the very important attribute for deciding which collection implementation is to use. Ordered means the retrival order
will be the same as the inserted order. For e.g if you insert say 10, 7, 4, 6 numbers into collection when we retrieve we should get in the same order i.e as 10, 7, 4, 6.

List implementation classes such as ArrayList, LinkedList supports ordering.
Map implementation classes such as HashMap, TreeMap does not supports ordering.
Set implementation classes such as HashSet, TreeSet does not supports ordering.

Then if i want to maintain order in case of Map & set how i can do that ? Most of the people write their own logic for this.
But no need. JAVA always makes developers life easier by suporting implementations required for most of our requirements.

Map has a implementation class called LinkedHashMap which supports ordering.
Set has a implementation class called LinkedHashSet which supports ordering.

Motivation Tip of the Day
Don’t expect everyone to do things your way. Allowing people to be creative creates a more optimistic environment and can lead to awesome new ideas.
Interesting Fact
“The World’s best selling book is The Holy Bible”

Inspirational Quote
“If you think, you can”

Leave a comment