Sunday, January 20, 2013

Java Today: Servlets

Java Today: Servlets:                 Basic Information about Servlets in Java: 1. Servlets are server side components that provide a powerful mechanism...

Interview Questions - Servlets and latest version







Hi Friends...!!..

Check out the new version of Java7. You may click the link below

http://www.java.com/en/download/index.jsp

Some brief information about Java:


1. Java is a general-purpose, concurrent, class-based, object-oriented computer programming language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" meaning that code that runs on one platform does not need to be recompiled to run on another.

2.  Java applications are typically compiled to bytecode (class file) that can run on any JVM regardless of computer architecture. Java is, as of 2012, one of the most popular programming languages in use, particularly for client-server web applications, with a reported 15 million users. Java was originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C++, but it has fewer low-level facilities than either of them.

Some questions about Servlets:
Technical Interviewers ask mostly from this topic just to check your basic skills.

Q:
What is the difference between HttpServlet and GenericServlet?
A:
A GenericServlet has a service() method aimed to handle requests. 
HttpServlet extends GenericServlet and adds support for doGet(), 
doPost(), doHead() methods (HTTP 1.0) plus doPut(), doOptions(), 
doDelete(), doTrace() methods (HTTP). 
Both these classes are abstract.




Q:
What is the difference between ServletContext and ServletConfig?
A:
ServletContext: 
Defines a set of methods that a servlet uses to 
communicate with its servlet container, for example, to get the 
MIME type of a file, dispatch requests, or write to a log file.
The ServletContext object is contained within the ServletConfig object,
 which the Web server provides the servlet when the servlet is initialized 

ServletConfig: 
The object created after a servlet is instantiated and 
its default constructor is read. It is created to pass initialization information
 to the servlet.