Posted on September 27, 2006 by sharat
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 [...]
Filed under: XML | 46 Comments »
Posted on September 26, 2006 by sharat
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
Filed under: XML | 4 Comments »
Posted on September 9, 2006 by sharat
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” />
Filed under: Struts | 2 Comments »
Posted on September 9, 2006 by sharat
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.
Filed under: Struts | 1 Comment »
Posted on September 9, 2006 by sharat
Core classes of Struts Framework are ActionForm, Action, ActionMapping, ActionForward, ActionServlet etc.
Filed under: Struts | 5 Comments »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: Struts | Leave a Comment »
Posted on September 9, 2006 by sharat
<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”/>
Filed under: Struts | 8 Comments »
Posted on September 9, 2006 by sharat
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).
Filed under: Struts | Leave a Comment »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: Struts | 1 Comment »
Posted on September 9, 2006 by sharat
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.
Filed under: Struts | 4 Comments »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: Struts | 5 Comments »
Posted on September 9, 2006 by sharat
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>
Filed under: Struts | 6 Comments »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: Struts | 4 Comments »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: Struts | 21 Comments »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: Struts | 3 Comments »
Posted on September 9, 2006 by sharat
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, [...]
Filed under: Struts | 1 Comment »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: Struts | 10 Comments »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: Struts | 1 Comment »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: Struts | 3 Comments »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: Struts | Leave a Comment »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: Struts | 1 Comment »
Posted on September 9, 2006 by sharat
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.
Filed under: Struts | Leave a Comment »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: Struts | 2 Comments »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: JDBC | 2 Comments »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
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();
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
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”);
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
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();
Filed under: JDBC | 1 Comment »
Posted on September 9, 2006 by sharat
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.
Filed under: JDBC | 1 Comment »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: JDBC | 7 Comments »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: JDBC | 1 Comment »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: JDBC | 12 Comments »
Posted on September 9, 2006 by sharat
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.
Filed under: JDBC | 1 Comment »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: JDBC | 6 Comments »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: JDBC | Leave a Comment »
Posted on September 9, 2006 by sharat
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 [...]
Filed under: JDBC | 2 Comments »
Posted on September 8, 2006 by sharat
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 [...]
Filed under: JDBC | 7 Comments »
Posted on September 8, 2006 by sharat
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 [...]
Filed under: JDBC | 5 Comments »
Posted on September 8, 2006 by sharat
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 [...]
Filed under: JDBC | Leave a Comment »
Posted on September 8, 2006 by sharat
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 [...]
Filed under: JDBC | 1 Comment »
Posted on September 8, 2006 by sharat
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. [...]
Filed under: JSP | 5 Comments »
Posted on September 7, 2006 by sharat
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 [...]
Filed under: Servlets | 17 Comments »
Posted on September 7, 2006 by sharat
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 [...]
Filed under: Servlets | 10 Comments »
Posted on September 7, 2006 by sharat
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 [...]
Filed under: Servlets | 1 Comment »
Posted on September 7, 2006 by sharat
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 [...]
Filed under: JSP | Leave a Comment »
Posted on September 7, 2006 by sharat
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 [...]
Filed under: JSP | 2 Comments »
Posted on September 7, 2006 by sharat
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. [...]
Filed under: JSP | Leave a Comment »
Posted on September 7, 2006 by sharat
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 [...]
Filed under: JSP | 1 Comment »
Posted on September 6, 2006 by sharat
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 [...]
Filed under: Servlets | 8 Comments »
Posted on September 6, 2006 by sharat
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 [...]
Filed under: Servlets | 9 Comments »
Posted on September 6, 2006 by sharat
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 [...]
Filed under: JSP | 9 Comments »
Posted on September 6, 2006 by sharat
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.
Filed under: JSP | Leave a Comment »
Posted on September 6, 2006 by sharat
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. [...]
Filed under: JSP | Leave a Comment »
Posted on September 6, 2006 by sharat
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, [...]
Filed under: JSP | Leave a Comment »
Posted on September 6, 2006 by sharat
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 [...]
Filed under: JSP | Leave a Comment »
Posted on September 6, 2006 by sharat
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, [...]
Filed under: JSP | Leave a Comment »
Posted on September 6, 2006 by sharat
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 [...]
Filed under: JSP | Leave a Comment »
Posted on September 6, 2006 by sharat
* 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 [...]
Filed under: JSP | 2 Comments »
Posted on September 5, 2006 by sharat
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 [...]
Filed under: JSP | 16 Comments »
Posted on September 5, 2006 by sharat
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 [...]
Filed under: JSP | Leave a Comment »
Posted on September 5, 2006 by sharat
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 [...]
Filed under: JSP | 3 Comments »
Posted on September 5, 2006 by sharat
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 [...]
Filed under: JSP | 4 Comments »