Friday, March 26, 2010

What are implicit objects?

Implicit Objects:

Implicit Objects in JSP are objects that are automatically available in JSP. Implicit Objects are Java objects that the JSP Container provides to a developer to access them in their program using JavaBeans and Servlets. These objects are called implicit objects because they are automatically instantiated.

Following are the implicit Objects

request
response
session
application
page
pageContext
out
config
exception


What is difference between HashMap and HashTable and HashSet and TreeSet?

Hashtable
Hashtable is basically a data structure to retain values of key-value pair
  •  It didn’t allow null for both key and value. You will get NullPointerException if you add null value.
  • It is synchronized. So it comes with its cost. Only one thread can access in one time. So It is slow.
HashMap
Like Hashtable it also accepts key value pair.
  • It allows null for both key and value. 
  • It is unsynchronized. So come up with better performance(fast)

HashSet
It is from Set family.
  • HashSet does not allow duplicate values. 
  • It provides add method rather put method. 
  • You also use its contains method to check whether the object is already available in HashSet. 
  • HashSet can be used where you want to maintain a unique set but not the order. 


TreeSet
 It is also from Set family.
  • Likely HashSet, TreeSet does not allow duplicate values.
  • It provides add method rather put method. 
  • You also use its contains method to check whether the object is already available in TreeSet. 
  • TreeSet can be used where you want to maintain a unique set as well as the order.