FAQs About Advance Java

SERVLET
Q. What is a Servlet?
A servlet is a Java technology and it is managed by a container called servlet engine. It generates dynamic content and interacts with client through Request and Response. Servlets are mostly used because they are platform-independent Java classes and are compiled to platform-neutral byte code. Java byte code can be loaded dynamically into and run by java enabled web server.

Q. Why GenericServlet is an abstract class ?
A. It is not recommonded to override the all methods of abstract class., that is why the the vendors make generic servlet as abstract

Q. What is the difference between GenericServlet and HttpServlet?
A. GenericServlet is for servlets that might not use HTTP, like for instance FTP service.As of only Http is implemented completely in HttpServlet. The GenericServlet has a service() method that gets called when a client request is made. This means that it gets called by both incoming requests and the HTTP requests are given to the servlet as they are.

Q. What is difference between Servlet and Applet
A. Servlet run inside a servlet container on the server side where as applet run on the client side inside a browser.

Q. What is the diff b/w doGet() and service() method
A. Service method orginates from Generic Servlet and so service method is used to do something which does not involve http protocol. service handles standard HTTP requests by dispatching them to the handler methods(doXXX) for each HTTP request type

Q. 6. What is called a session?
A. A session is an object which is used by a servlet and it is used to track user interaction with a web application across multiple HTTP requests.




JDBC
Q. Explain Basic Steps in writing a Java program using JDBC.
A. JDBC makes the interaction with RDBMS simple and intuitive. When a Java application needs to access database :

  • Load the RDBMS specific JDBC driver because this driver actually communicates with the database.
  • Open the connection to database, for sending SQL statements and get results back.
  • Create JDBC Statement object containing SQL query.
  • Execute statement which returns result set that contains the tuples of database table.
  • Process the result set.
  • Close the connection.








No comments:

Post a Comment