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 »