Wednesday 27 March 2013

How many ways can we track client and what are they?


How many ways can we track client and what are they? 
 The servlet API provides two ways to track client state and they are: a) Using Session tracking and b) Using Cookies.



Blog Author: Vijay Kumar

What are the different servers available for developing and deploying Servlets?


What are the different servers available for developing and deploying Servlets?  
a) Java Web Server 
b) JRun 
g) Apache Server 
h) Netscape Information Server
 i) Web Logic

Blog Author: Vijay Kumar


Who is loading the init() method of servlet?


Who is loading the init() method of servlet?  

Web server

Blog Author: Vijay Kumar


What is the life cycle of a servlet?


What is the life cycle of a servlet?  
Each Servlet has the same life cycle: 
a) A server loads and initializes the servlet by init () method. 
b) The servlet handles zero or more client’s requests through service() method. 
c) The server removes the servlet through destroy() method.

Blog Author: Vijay Kumar


What is the difference between doPost and doGet methods?


What is the difference between doPost and doGet methods?  
a) doGet() method is used to get information, while doPost() method is used for posting information. b) doGet() requests can’t send large amount of information and is limited to 240-255 characters. However, doPost()requests passes all of its data, of unlimited length. 
c) A doGet() request is appended to the request URL in a query string and this allows the exchange is visible to the client, whereas a doPost() request passes directly over the socket connection as part of its HTTP request body and the exchange are invisible to the client.

Blog Author: Vijay Kumar


What is the difference between an applet and a servlet?


What is the difference between an applet and a servlet?  
a) Servlets are to servers what applets are to browsers. b) Applets must have graphical user interfaces whereas servlets have no graphical user interfaces.

Blog Author: Vijay Kumar


What is servlet?


What is servlet? 
 Servlets are modules that extend request/response-oriented servers, such as java-enabled web servers. For example, a servlet might be responsible for taking data in an HTML order-entry form and applying the business logic used to update a company’s order database.

Blog Author: Vijay Kumar


How to create and call stored procedures?


How to create and call stored procedures?  
To create stored procedures: Create procedure procedurename (specify in, out and in out parameters) BEGIN Any multiple SQL statement; END; To call stored procedures: CallableStatement csmt = con. prepareCall(”{call procedure name(?,?)}”); csmt. registerOutParameter(column no. , data type); csmt. setInt(column no. , column name) csmt. execute();



Blog Author: Vijay Kumar

What is stored procedure?


What is stored procedure?  
Stored procedure is a group of SQL statements that forms a logical unit and performs a particular task. Stored Procedures are used to encapsulate a set of operations or queries to execute on database. Stored procedures can be compiled and executed with different parameters and results and may have any combination of input/output parameters.

Blog Author: Vijay Kumar


What are the types of statements in JDBC?


What are the types of statements in JDBC?  
Statement: to be used createStatement() method for executing single SQL statement PreparedStatement — To be used preparedStatement() method for executing same SQL statement over and over. CallableStatement — To be used prepareCall() method for multiple SQL statements over and over.

Blog Author: Vijay Kumar


What type of driver did you use in project?


What type of driver did you use in project?  
JDBC-ODBC Bridge driver (is a driver that uses native(C language) libraries and makes calls to an existing ODBC driver to access a database engine).

Blog Author: Vijay Kumar


What are the steps involved for making a connection with a database or how do you connect to a database?


What are the steps involved for making a connection with a database or how do you connect to a database?
a) Loading the driver : To load the driver, Class. forName() method is used. Class. forName(”sun. jdbc. odbc. JdbcOdbcDriver”); When the driver is loaded, it registers itself with the java. sql. DriverManager class as an available database driver. b) Making a connection with database: To open a connection to a given database, DriverManager. getConnection() method is used. Connection con = DriverManager. getConnection (”jdbc:odbc:somedb”, “user”, “password”); c) Executing SQL statements : To execute a SQL query, java. sql. statements class is used. createStatement() method of Connection to obtain a new Statement object. Statement stmt = con. createStatement(); A query that returns data can be executed using the executeQuery() method of Statement. This method executes the statement and returns a java. sql. ResultSet that encapsulates the retrieved data: ResultSet rs = stmt. executeQuery(”SELECT * FROM some table”); d) Process the results : ResultSet returns one row at a time. Next() method of ResultSet object can be called to move to the next row. The getString() and getObject() methods are used for retrieving column values: while(rs. next()) { String event = rs. getString(”event”); Object count = (Integer) rs. getObject(”count”);

Blog Author: Vijay Kumar