83. What are the differences between SAX and DOM parser.

SAX DOM Both SAX and DOM are used to parse the XML document. Both has advantages and disadvantages and can be used in our programming depending on the situation. Parses node by node Stores the entire XML document into memory before processing Doesn’t store the XML in memory Occupies more memory We cant insert or [...]

82. Describe the differences between XML and HTML

XML HTML User definable tags Defined set of tags designed for web display Content driven Format driven End tags required for well formed documents End tags not required Quotes required around attributes values Quotes not required Slash required in empty tags Slash not required

81. How you will make available any message resources definations file to the struts famework environment.

Message Resources Definitions file are simple .properties files and these files contains the messages that can be used in the struts project. Message Resources Definitions files can be added to the struts-config.xml file through <message-resources /> tag.Example:<message-resources parameter=”MessageResources” />

80. What is Jakarta Struts FrameWork

Jakarta Struts is open source implementation of MVC (Model-View-Controller) pattern for the development of web based applications. Jakarta Struts is robust architecture and can be used for the development of application of any size. Struts framework makes it much easier to design scalable, reliable Web applications with Java.

79. What are the core classes of the Struts Frame Work

Core classes of Struts Framework are ActionForm, Action, ActionMapping, ActionForward, ActionServlet etc.

78. What are the components of Struts

Struts is based on the MVC design pattern. Struts components can be categories into Model, View and Controller. Model: Components like business logic / business processes and data are the part of Model. View: JSP, HTML etc. are part of View Controller: Action Servlet of Struts is part of Controller components which works as front [...]

77. What are differences between <bean:message> and <bean:write>

<bean:message>: This tag is used to output locale-specific text (from the properties files) from a MessageResources bundle.  <bean:message key=”label.search.name”/> <bean:write>: This tag is used to output property values from a bean. <bean:write> is a commonly used tag which enables the programmers to easily present the data. <bean:write name=”student” property=”age”/>

76. What is LookupDispatchAction

An abstract Action that dispatches to the subclass mapped execute method. This is useful in cases where an HTML form has multiple submit buttons with the same name. The button name is specified by the parameter property of the corresponding ActionMapping. (Ref. http://struts.apache.org/1.2.7/api/org/apache/struts/actions/LookupDispatchAction.html).

75. What is struts flow

Struts Flow is a port of Cocoon’s Control Flow to Struts to allow complex workflow, like multi-form wizards, to be easily implemented using continuations-capable JavaScript. It provides the ability to describe the order of Web pages that have to be sent to the client, at any given point in time in an application. The code [...]

74. How to handle exceptions in struts

In Struts you can handle the exceptions in two ways:a) Declarative Exception Handling: You can either define global exception handling tags in your struts-config.xml or define the exception handling tags within <action>..</action> tag. Example: <exception   key=”database.error.duplicate”                     path=”/UserExists.jsp”                     type=”mybank.account.DuplicateUserException”/> b) Programmatic Exception Handling: Here you can use try{}catch{} block to handle the exception.

73. What is the Action Errors and Action Message?

ActionMessage: A class that encapsulates messages. Messages can be either global or they are specific to a particular bean property.Each individual message is described by an ActionMessage object, which contains a message key (to be looked up in an appropriate message resources database), and up to four placeholder arguments used for parametric substitution in the [...]

72. How to setup struts to use multiple configuration files.

Struts can use multiple configuration files. Here is the configuration example:<servlet>        <servlet-name>banking</servlet-name>        <servlet-class>org.apache.struts.action.ActionServlet        </servlet-class>        <init-param>        <param-name>config</param-name>        <param-value>/WEB-INF/struts-config.xml,                /WEB-INF/struts-authentication.xml,                /WEB-INF/struts-help.xml           </param-value>    </init-param>

71. What we will define in struts-config.xml file.

The main control file in the Struts framework is the struts-config.xml XML file, where action mappings are specified. This file’s structure is described by the struts-config DTD file, which is defined at http://jakarta.apache.org/struts/. A copy of the DTD can be found on the /docs/dtds subdirectory of the framework’s installation root directory. The top-level element is [...]

70. What is the request processor in struts and how it works

The RequestProcessor Class is the actual place where the request processing takes place in a Struts controller environment. When the request object first reaches the actionservlet class then it invokes the process method of the underlying RequestProcessor Class. This process method then looks into the struts-config.xml file and tries to locate the name of the [...]

69. What is struts actions and action mappings.

A Struts action is an instance of a subclass of an Action class, which implements a portion of a Web application and whose perform or execute method returns a forward. An action can perform tasks such as validating a user name and password. An action mapping is a configuration file entry that, in general, associates [...]

68. What are the various struts tag libraries.

Struts is very rich framework and it provides very good and user friendly way to develop web application forms. Struts provide many tag libraries to ease the development of web applications. These tag libraries are: Bean tag library – Tags for accessing JavaBeans and their properties. HTML tag library – Tags to output standard HTML, [...]

67. What is the difference between perform() and execute()

Perform method is the method which was deprecated in the Struts Version 1.1.  In Struts 1.x, Action.perform() is the method called by the ActionServlet. This is typically where your business logic resides, or at least the flow control to your JavaBeans and EJBs that handle your business logic. As we already mentioned, to support declarative [...]

66.How to enable front-end validation based on the xml in validation.xml

The <html:javascript> tag to allow front-end validation based on the xml in validation.xml. For  example the code: <html:javascript  formName=”logonForm”                          dynamicJavascript=”true”                          staticJavascript=”true”  />  generates the client side java script for the form “logonForm” as defined in the  validation.xml file. The <html:javascript> when added in the jsp file generates the client site validation script. Following [...]

65. What is the Struts Validator Framework

Struts Framework provides the functionality to validate the form data. It can be use to validate the data on the users browser as well as on the server side. Struts Framework emits the java scripts and it can be used validate the form data on the client browser. Server side validation of form can be [...]

64. What is Action Class

The Action is part of the controller. The purpose of Action Class is to translate the HttpServletRequest to the business logic. To use the Action, we need to  Subclass and overwrite the execute()  method. The ActionServlet (commad) passes the parameterized class to Action Form using the execute() method. There should be no database interactions in [...]

63. Explain ActionFrom Class and its life cycle.

An ActionForm is a java bean that extends org.apache.struts.action.ActionForm, ActionForm maintain the session state of web application. All data submitted by the user are sent corresponding ActionForm  ActionForm class is used to capture user-input data from an HTML form and transfer it to the Action Class. ActionForm plays the role of Transport Vehicle between the presentation Tire [...]

62. What are new features of Struts 1.1

The new features added to Struts 1.1 are 1. RequestProcessor class 2. Method perform() replaced by execute() in Struts base Action Class 3. Changes to web.xml and struts-config.xml4.Declarative exception handling5.Dynamic ActionForms6.Plug-ins7.Multiple Application Modules8.Nested Tags9.The Struts Validator10.Change to the ORO package11.Change to Commons logging12.Removal of Admin actions13. Deprecation of the GenericDataSource.

61. What is a Action Servlet

public class ActionServlet extends javax.servlet.http.HttpServlet ActionServlet provides the “controller” in the Model-View-Controller (MVC) design pattern for web applications that is commonly known as “Model 2″. The class org.apache.struts.action.ActionServlet is the called the ActionServlet. In the the Jakarta Struts Framework this class plays the role of controller. All the requests to the server goes through the [...]

60. What is the difference between TYPE_SCROLL_INSENSITIVE and TYPE_SCROLL_SENSITIVE

You will get a scrollable ResultSet object if you specify one of these ResultSet constants.The difference between the two has to do with whether a result set reflects changes that are made to it while it is open and whether certain methods can be called to detect these changes. Generally speaking, a result set that [...]

59. How to make updates to updatable result sets.

Another new feature in the JDBC 2.0 API is the ability to update rows in a result set using methods in the Java programming language rather than having to send an SQL command. But before you can take advantage of this capability, you need to create a ResultSet object that is updatable. In order to [...]

58. How to Retrieve Warnings

SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the execution of an application, as exceptions do; they simply alert the user that something did not happen as planned. A warning can be reported on a Connection object, a Statement object (including PreparedStatement and CallableStatement objects), or [...]

57. How can you load the driver.

Driver can be loaded in 2 ways : 1. class.forName(“sun.jdbc.odbc.JdbcOdbc”); 2. Driver d=new Driver(“sun.jdbc.odbc.JdbcOdbc”);    DriverManager.registerDriver(d); vendar specific one: Driver d=new oracle.driver.oracleDriver();

56. How can you retrieve data from the ResultSet

Example: Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(SELECT COF_NAME, PRICE FROM COFFEES”); while (rs .next() ) { //Iam assuming there are 3 columns in the table. System.out.println ( rs.getString(1)); System.out.println(rs.getString(2)); System.out.println(rs.getString(3)); } //don’t forget to close the resultset, statement & connection rs.close(); //First  stmt.close(); //Second con.close(); //Last  System.out.println(“You are done”); 

55. How do you implement Connection Pooling

Connection Pooling can be implemented by the following way.   A javax.sql.ConnectionPoolDataSource interface that serves as a resource manager connection factory for pooled java.sql.Connection objects. Each database vendors provide the implementation for that interface.  For example, the oracle vendors implementation is as follows: oracle.jdbc.pool.oracleConnectionPoolDataSource Class.  A javax.sql.PooledConnection interface encapsulates the physical connection for the database. Again, the [...]

54. How to call a stored procedure from JDBC

Stored Procedures can be called in java by using the prepareCall() method which returns a CallableStatement object. CallableStatement cs = con.prepareCall(“{call Procedure_name}”); ResultSet rs = cs.executeQuery();

53. What are the three statements in JDBC & difference between them.

1.Statement which is used to run simple sql statements like select and update 2. PrepareStatment is used to run Pre compiled sql.  3. CallableStatement is used to execute the stored procedures.

52. What is the difference between ResultSet and RowSet

A ResultSet maintains a connection to a database and because of that it can’t be serialized and also we cant pass the Resultset object from one class to other class across the network. RowSet is a disconnected, serializable version of a JDBC ResultSet and also the RowSet extends the ResultSet interface so it has all [...]

51. What is a transaction.

To emulate a business transaction, a program may need to perform several steps. A financial program, for example, might transfer funds from a checking account to a savings account with the steps listed in the following pseudocode: begin transaction debit checking account credit savings account update history log commit transaction Either all three of these [...]

50. What is the purpose of setAutoCommit()

Autocommit behavior    The JDBC specification requires that, by default, a COMMIT is performed after each data modification statement. Currently, the server-side JDBC behavior is to commit. You can control this behavior using a statement such as the following: conn.setAutoCommit( false ) ; where conn is the current connection object. Connection defaults    From server-side JDBC, only the first [...]

49. What is the difference between statement and prepared statment?

Prepared Statement is Pre-compiled class , but Statement is not. So in PreparedStatement the execution will be faster. Actually when u submit a simple statement to the databse, at first the DBMS parses it and sends it back with the result, so again when u send the same statement again the DBMS server parses it [...]

48. What is a savepoint.

Save point is a feature using which we can save  status of the transaction to a perticular extent.so that if anytime we have lost a transaction we can get it back using save point.

47. What is the difference between ResultSetMetaData and DatabaseMetaData

ResultSetMetaData You can interrogate JDBC for detailed information about a query’s result set using a ResultSetMetaData object. ResultSetMetaData is a class that is used to find information about the ResultSet returned from a executeQuery call. It contains information about the number of columns, the types of data they contain, the names of the columns, and [...]

46. What do you mean by batch update

The JDBC drivers that support JDBC 2.0 and above support batch updates. With batch updates, instead of updating rows of a  table one at a time, you can direct JDBC to execute a group of updates at the same time. Statements that can be included in the same batch of updates are known as batchable [...]

45. What is the difference between local and global transaction.

A transaction is atomic unit of Work.The tasks which are made into the transaction act as a unit which can be executed successfully all,or if at least one task fails to its promise ,then the effect of all the tasks are to be rollbacked.Thus transaction is committed or rolled backed. Transactions can be divided into [...]

44. What the new features in JDBC 2.0

The following are the JDBC 2.0 features. Resultset enhancements JDBC 2.0 supports scrollable resultset capability under three major headings, namely, forward-only, scroll-insensitive, and scroll-sensitive. Each of these resultsets can in turn be Read_only or Updatable. Forward_only/Read_only is feature of JDBC 1.0. Batch Updates automatic batch update and explicit batch update. Advanced Data Types The advanced [...]

43. Explain JDBC Driver Types

JDBC drivers are divided into four types or levels. Each type defines a JDBC driver implementation with increasingly higher levels of platform independence, performance, and deployment administration. The four types are: Type 1: JDBC-ODBC Bridge Type 2: Native-API/partly Java driver Type 3: Net-protocol/all-Java driver Type 4: Native-protocol/all-Java driver Type 1: JDBC-ODBC Bridge  The type 1 [...]

42. What is JDBC

JDBC (Java Database Connectivity) provides a standard interface for accessing a relational database from a Java application regardless of where the application is running and where the database is. It provides a way for Java applications to call SQL and PL/SQL. In other words it is a way to execute SQL statements and also call [...]

41. Explain Basic Steps in writing a Java program using JDBC

Basically a Java program implementing JDBC performs the following functions: Load a JDBC driver. Establish a database connection. Optionally interrogate the database for capability subset. Optionally retrieve schema metadata information. Construct a SQL or callable statement object and send queries or database tasks. Execute the database tasks or process resultsets. Close the statement object and [...]

40. What is the difference between <jsp:include> and <c:import>

The <c:import> tag imports a resource specified by a URL and exposes it to the page, variable, or reader. The <jsp:include> standard action is a request-time action that will include the output of another JSP at the location of the tag within the calling JSP. <c:import> is similar to the <jsp:include> directive, but with more features. [...]

39. What is the differences between Http Servlet and generic Servlet

HttpServlet Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A subclass of HttpServlet must override at least one method, usually one of these: doGet, if the servlet supports HTTP GET requests doPost, for HTTP POST requests doPut, for HTTP PUT requests doDelete, for HTTP DELETE requests [...]

38. Servlets 20 mins drill and Quiz.

What is the servlet? Servlet is a script, which resides and executes on server side, to create dynamic HTML. In servlet programming we will use java language. A servlet can handle multiple requests concurrently What’s the difference between servlets and applets? Servlets executes on Servers. Applets executes on browser. Unlike applets, however, servlets have no [...]

37. What is servlet lazy loading.

A container doesnot initialize the servlets ass soon as it starts up, it initializes a servlet when it receives a request for that servlet first time. This is called lazy loading. The servlet specification defines the <load-on-startup> element, which can be specified in the deployment descriptor to make the servlet container load and initialize the [...]

36. Sir, do you know about jsp application object

This implicit object represents the application to which the JSP belongs.  JSPs are grouped into applications according to their URLs where the first directory name in a URL defines the application. The application object contains methods that provide information about the JSP Container, support for logging plus utility methods for example translating a relative URL [...]

35. Tell me something about jsp session object

The session implicit object is used to provide an association between the client and the server. This association, or session, persists over multiple connections and/or requests during a given time period. Sessions are used to maintain state and user identity across multiple page requests. A session can be maintained either by using cookies or by [...]

34. What do you know about jsp response object

The response object handles the output to the client. This object can be used for creating HTTP Headers, creating cookies, setting content type and redirecting workflow. Servlet Class javax.servlet.http.HttpServletResponse The following table summarises the most useful methods available to the response object. Method Description setContentType() Sets the MIME type and character encoding for the page. [...]

33. Explain request implicit object

The request object retrieves the values that the client browser passed to the server during an HTTP request such as headers, cookies or parameters associated with the request. Among the most common use of the request object is to obtain parammeter or query string values. Servlet Class javax.servlet.HttpServletRequest The following table summarises the most useful [...]

32. What is the difference between ServletContext and ServletConfig

public interface 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. There is one context per “web application” per Java Virtual Machine. The ServletContext object is contained within the ServletConfig [...]

31. Explain Servlet Life Cycle.

Servlets are normal Java classes which are created when needed and destroyed when not needed. Since Servlets run within a Servlet Container, creation and destruction of Servlets is the duty of Servlet Container and not yours. Implementing the init() and destory() methods of Servlet interface allows you to be told by the Servlet Container that [...]

30. Explain the advantages of JSTL

The Java Standard Tag Library (JSTL) is a standardized collection of custom tags. It has a number of tags for common tasks such as iterating through lists, interacting with databases, handling XML data, formatting data, and much more. The latest version of JSTL is 1.1. An implementation of JSTL can be downloaded from the Apache [...]

29. What are the advantages of JSP

Separation of static from dynamic content. Write Once Run Anywhere. Dynamic content can be served in a variety of formats.             example: browsers using HTML/DHTML, to handheld wireless devices like mobile phones and PDAs using WML, to other B2B applications using XML Recommended Web access layer for n-tier architecture. Completely leverages the Servlet API.

28. Explain JSP Basic Structure Items.

JSP Expression <%= expression %> Expression is evaluated and placed in output. XML equivalent is<jsp:expression>expression</jsp:expression>. Predefined variables are request,response,out,session,application,config, andpageContext (available in scriptlets also). JSP Scriptlet <% code %> Code is inserted in service method. XML equivalent is<jsp:scriptlet>code</jsp:scriptlet>. JSP Declaration <%! code %> Code is inserted in body of servlet class, outside of service method. [...]

27. How to handle cookies in JSP

The getCookies() method of the request object returns an array of Cookie objects. Cookies are used to allow web browsers to hold small amounts of information or state data associated with a user’s web browsing. Cookies are named and have a single value. They may have optional attributes, including a comment presented to the user, [...]

26. Explain JSP Session implicit Object.

The session implicit object is used to provide an association between the client and the server. This association, or session, persists over multiple connections and/or requests during a given time period. Sessions are used to maintain state and user identity across multiple page requests. A session can be maintained either by using cookies or by [...]

25. What is Session Tracking.

There are a number of problems that arise from the fact that HTTP is a “stateless” protocol. In particular, when you are doing on-line shopping, it is a real annoyance that the Web server can’t easily remember previous transactions. This makes applications like shopping carts very problematic: when you add an entry to your cart, [...]

24. How can JSP inheritance be achieved

The JSP super class and sub-class need to satisfy certain requirements as defined in the sections below. First let us assume we are using the HTTP protocol. Then mapping of other protocols is an easy task. Requirements for the Super Class It must implement the HttpJspPage interface. It will obviously extend the HttpServlet class. It [...]

23. Explain about JSP Standard Action

* The use of JavaBeans within JSP pages is a system for accessing Java components through the standard interface of methods with set and get prefixes. * The general syntax for the useBean tag is as follows. <jsp:useBean id=”myBean” type=”classtype” class=”com.domain.ClassName” scope=”session” />    #  The it attribute id mandatory and can be an arbitrary [...]

22. Discuss the scope of a variable declared in Declaration part and in scriptlet part.

Variable declared inside declaration part is treated as a global variable.that means after convertion jsp file into servlet that variable will be in outside of service method or it will be declared as instance variable. the scope is available to complete jsp and to complete in the converted servlet class. Variable declared inside a scriplet [...]

21. How can I enable session tracking for JSP pages if the browser has disabled cookies?

Session tracking uses cookies by default to associate a session identifier with a unique user. If the browser does not support cookies, or if cookies are disabled, you can still enable session tracking using URL rewriting. URL rewriting essentially includes the session ID within the link itself as a name/value pair. However, for this to [...]

20. How does JSP handle run-time exceptions

You can use the errorPage attribute of the page directive to have uncaught run-time exceptions automatically forwarded to an error processing page. For example: <%@ page errorPage=”error.jsp” %> redirects the browser to the JSP page error.jsp if an uncaught exception is encountered during request processing. Within error.jsp, if you indicate that it is an error-processing [...]

19. Explain the life cycle of a JSP.

A JSP page services requests as a servlet. Thus, the life cycle and many of the capabilities of JSP pages (in particular the dynamic aspects) are determined by Java Servlet technology. JSP page translation JSP page compilation load class create instance call the jspInit method call the _jspService method call the jspDestroy method              When [...]

Follow

Get every new post delivered to your Inbox.