Monday, April 12, 2010

JAR WAR and EAR Files

JAR Files (Java Archive):

  1. These files are with the .jar extension.
  2. The .jar files contain the classes, libraries, resources and accessories files like property files.

WAR Files (Web Archive):

  1. These files are with the .war extension.
  2. The war file contains JSP, html, JavaScript and other files for necessary for the development of web applications.
  3. The war file contains the web application that can be deployed on the any servlet/jsp container.

EAR Files:

  1. These files are with the .ear extension.
  2. The .ear file contains the EJB modules of the applications.
  3. The ear file contains the ejb application that can be deployed on the any application server with ejb container.


 

Difference between customTags and JavaBeans


  1. JavaBeans are the data handlers of JSP and aid in encapsulating data management logic. They are used for storage Tags on the other hand, aid computational logic related to a particular request. 
  2. Tags are thread safe; beans are not. Beans like other separate utility classes, have to be made thread safe by the developers. 
  3. Tags are aware of the environment (the page context) in which they execute. Beans are not. 
  4. Tags remain in the translation unit.We can think of tags as events occuring in the execution of a JSP page. Beans are object stores that reside outside the translation unit. 
  5. Tags can access implicit objects. Beans are cannot. 
  6. Tags only have page scope. They are created and destroyed withen a single request and in a single page. They can access other objects in all the scopes, though. Beans, on the other hand. Are themselves objects that reside in different scopes. Therefore, tags can access and manipulte beans, while beans do not access and manipulate tags. 
  7. The Tag Extension API designed closely with the concept of a JSP page in mind. They may not be used in other applications. Beans, on the other hand are supposed to be resuable compnents and can be used by other container. 
  8. Tags are not persistent objects. Beans have properties, and properties have values. A set of values is called the state of the bean. This state can be persisted via serialization and resued later.

Sunday, April 11, 2010

JSP Standard Actions

JSP standard actions are commands given to the JSP engine. They direct the engine to perform certain tasks during the execution of a page.
e.g. The following line instructs the engine to forward request to another JSP page, welcome.jsp from current JSP page.

<jsp:forward page="welcome.jsp"/>


There are six standard JSP actions:
  1. jsp:include
  2. jsp:forward
  3. jsp:useBean
  4. jsp:setProperty
  5. jsp:getProperty
  6. jsp:plugin

Saturday, April 10, 2010

Difference between GET Method and POST Method

GET Method
  1. Target resource type is Active or passive
  2. Type of data is Text
  3. The amount of data handled by GET Method is not more than 255 characters.
  4. Data is part of the URL and is visible to the user in the URL field of browser.
  5. Data can be cached in the browser's URL History.
POST Method
  1. Target resource type is Active
  2. Type of data is Text as well as Binary
  3. The amount of data handled by POST Method is unlimited.
  4. Data is not a part of the URL and is sent as the request message body. It is not visible to the user in the URL field of browser.
  5. Data is not cached in the browser's URL History.

Thursday, April 8, 2010

Difference between abstract class and interface

What is an Abstract Class?

  1. An abstract class is a special kind of class that cannot be instantiated.So the question is why we need a class that cannot be instantiated? An abstract class is only to be sub-classed (inherited from). In other words, it only allows other classes to inherit from it but cannot be instantiated. The advantage is that it enforces certain hierarchies for all the subclasses. In simple words, it is a kind of contract that forces all the subclasses to carry on the same hierarchies or standards.
  2.  A class may inherit only one abstract class.
  3. An abstract class can contain access modifiers for the subs, functions, properties
  4. Fast
  5. An abstract class can have fields and constants defined

What is an Interface?

  1. An interface is not a class. It is an entity that is defined by the word Interface. An interface has no implementation; it only has the signature or in other words, just the definition of the methods without the body. As one of the similarities to Abstract class, it is a contract that is used to define hierarchies for all subclasses or it defines specific set of methods and their arguments. The main difference between them is that a class can implement more than one interface but can only inherit from one abstract class.
  2. A class may inherit several interfaces.
  3. An interface cannot have access modifiers for the subs, functions, properties etc everything is assumed as public
  4. Requires more time to find the actual method in the corresponding classes.
  5. No fields can be defined in interfaces

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.