Consultancy Services jobs Etisalat CEO ZANTEL
etisalat

Custom Search
Share/Save/Bookmark Subscribe

Top Link

Posted by Anonymous | 11:55 AM | | 0 comments »

Etisalat

DEVELOPER

bangalore

india

BLOGGER

SEX



TOP LINK

What is TopLink?
Oracle TopLink builds high-performance applications that store persistent object-oriented data in a relational database. It successfully transforms object-orien

Figure 1–1 TopLink Runtime Architecture



Using TopLink, you can integrate persistence and object-transformation into your
application, while staying focused on your primary domain problem by taking advantage of an efficient, flexible, and field-proven solution (see "Solving the Object-Persistence Impedance Mismatch").

TopLink is suitable for use with a wide range of Java 2 Enterprise Edition (J2EE) and Java application architectures (see "TopLink Application Architectures").
Use TopLink to design, implement, deploy, and optimize an advanced, object-persistence and object-transformation layer that supports a variety of data sources and formats, including:

■ Relational–for transactional persistence of Java objects to a relational database
accessed using Java Database Connectivity (JDBC) drivers.
■ Object-Relational–for transactional persistence of Java objects to special purpose
structured data source representations optimized for storage in object-relational
databases such as Oracle Database.
■ Enterprise information system (EIS)–for transactional persistence of Java objects to
a nonrelational data source accessed using a J2EE Connector architecture (J2C)
adapter, and any supported EIS record type, including indexed, mapped, or XML.
■ XML–for nontransactional, nonpersistent (in-memory) conversion between Java
objects and XML Schema Document (XSD) based XML documents, using Java
Architecture for XML Binding (JAXB).

TopLink includes support for container-managed persistence (CMP) containers from a variety of vendors–such as Oracle Containers for J2EE (OC4J), IBM WebSphere application server, and BEA WebLogic Server–and support for base classes that simplify bean-managed persistence (BMP) development.

The extensive suite of development tools that TopLink provides, including Oracle
TopLink Workbench, lets you quickly capture and define object-to-data source and
object-to-data representation mappings in a flexible, efficient metadata format (see "Understanding TopLink Metadata" ).
The TopLink runtime lets your application exploit this mapping metadata with a simple session facade that provides in-depth support for data access, queries, transactions (both with and without an external transaction controller), and caching.
Solving the Object-Persistence Impedance Mismatch

Java-to-data source integration is a widely underestimated problem when creating enterprise Java applications. This complex problem involves more than simply reading from and writing to a data source.
The data source elements include tables, rows, columns, and primary and foreign keys. The Java and J2EE include entity classes (regular Java classes or Enterprise JavaBeans (EJB) entity beans), business rules, complex relationships, and inheritance. In a nonrelational data source, you must match your Java entities with EIS records or XML elements and schemas.
These differences (as shown in Figure 1–2) are known as the object-persistence impedance mismatch.

Figure 1–2 Solving Object-Persistence Impedance Mismatch



Successful solution requires bridging these different technologies, and solving the
object-persistence impedance mismatch–a challenging and resource-intensive
problem. To solve this problem, you must resolve the following issues between J2EE and data source elements:
■ Fundamentally different technologies
■ Different skill sets
■ Different staff and ownership for each of the technologies
■ Different modeling and design principles
Application developers need a product that enables them to integrate Java applications with any data source, without compromising ideal application design or data integrity. In addition, Java developers need the ability to store (that is, persist) and retrieve business domain objects using a relational database or a nonrelational data source as a repository.


TopLink Solution

TopLink addresses the disparity between Java objects and data sources. TopLink is a persistence framework that manages relational, object-relational, EIS, and XML mappings in a seamless manner.
This allows developers to rapidly build applications that combine the best aspects of object technology and the specific data source.

TopLink enables you to do the following:

■ Persist Java objects to virtually any relational database supported by a
JDBC-compliant driver.
■ Persist Java objects to virtually any nonrelational data source supported by a J2EE Connector architecture (J2C) adapter using indexed, mapped, or XML enterprise information system (EIS) records.
■ Perform in-memory conversions between Java objects and XML Schema (XSD)
based XML documents using JAXB.
■ Map any object model to any relational or nonrelational schema, using the Oracle TopLink Workbench graphical mapping tool.
■ Use TopLink successfully, even if you are unfamiliar with SQL or JDBC, because
TopLink offers a clear, object-oriented view of data sources.


TopLink Key Features

TopLink provides an extensive and thorough set of features. Java developers can use these features to rapidly build high-performance enterprise applications that are both scalable and maintainable.
Some of the primary features of TopLink are the following:
■ Nonintrusive, flexible, metadata-based architecture (see "Understanding TopLink
Metadata")
■ Comprehensive visual TopLink Workbench
■ Advanced mapping support and flexibility (relational, object-relational, EIS, and XML)
■ Object caching support
■ Query flexibility
■ Just-in-time reading
■ Caching
■ Object-level transaction support and integration
■ Locking
■ Multiple performance tuning options
■ Architectural flexibility
For additional information, see the TopLink page on OTN:
http://www.oracle.com/technology/products/ias/toplink/index.html




Struts Framework

Posted by Anonymous | 11:23 AM | 0 comments »

STRUTS framework





Struts is a well documented, mature and popular framework for building front ends to Java applications. To address concerns in software applications, it uses a Model-View-Controller (MVC) architecture: The Model represents the business or database code, the View represents the page design code, and the Controller represents the navigational code. The following diagram depicts the interactions between the key components of the WebSphere Commerce Web application. A brief description of each key component follows the diagram. For general information about Struts, refer to the Struts official home page.





Action servlet
Action servlet is a key controller component that implements the same methods and has the same life cycle as javax.servlet.http.HttpServlet.
As illustrated in steps 1 and 2 of the preceding diagram, the action servlet receives an HTTP request, uses the Struts configuration files to determine the appropriate application module, and routes the request to the module's request processor.

The action servlet is also responsible for initialization and clean-up of resources.
ECActionServlet (com.ibm.commerce.struts.ECActionServlet) is the WebSphere Commerce extension of the Struts ActionServlet class (org.apache.struts.action.ActionServlet). It provides additional functionality, such as the ability to refresh the Struts configuration without restarting the Web application, that is required by various WebSphere Commerce components.
This implementation is defined as the action servlet in the WebSphere Commerce Web application descriptor and must be used within the WebSphere Commerce Web application.

Request processor

Having received an HTTP request from the action servlet, the request processor, another key controller component, performs core request processing as follows:
1. Determines a number of request characteristics, such as locale and content type, necessary for further processing.
2. Uses the module's Struts configuration file to determine the configured action mapping for the request.
3. Uses the module's Struts configuration file to locate or instantiate an appropriate action form for the request, if necessary, and populates and validates it.
4. Uses the module's Struts configuration file to locate or instantiate an appropriate action for the request.
5. Passes the request, action form, and action mapping to the action (step 3 in the preceding diagram).
6. Forwards the user to the appropriate view element when the action is completed (step 6 in the preceding diagram).

By default, WebSphere Commerce is configured to use the standard request processor implementation provided by the Struts framework. Because it does not require a custom implementation, the WebSphere Commerce Web application can exploit any specialized request processor, such as one required for Tiles support.
Actions

Actions carry out the controller logic for the individual request, such as authorization and session logic, locating and calling the appropriate business (model) logic, and so forth.
Actions bridge an incoming request and the corresponding business logic that should be executed to process it. Actions use action form data to invoke business logic operations on behalf of the client (step 4 in the preceding diagram) and return an ActionForward object that indicates where the controller should forward the user (step 5 in the preceding diagram).
An Action class is created to support each type of request that can be received by the controller.
BaseAction ( com.ibm.commerce.struts.BaseAction) is the WebSphere Commerce extension of the Struts Action class (org.apache.struts.action.Action). It supplies the functionality that is necessary to invoke WebSphere Commerce commands based on the action's configuration as provided by the corresponding action mapping. The base action also provide additional callout hooks for the action to be extended to include addition pre and post processing logic.

Any custom action that invokes WebSphere Commerce commands must extend this class.

Action mappings

Action mappings represent the information that the controller knows about the mapping of a particular request to an instance of a particular Action class.
The request processor selects an appropriate action for each request based on the action mappings ( action-mapping elements) defined in the Struts configuration file.
The base ActionMapping class extends org.apache.struts.config.ActionConfig, which represents all configuration information provided in an action element of a Struts module configuration file.

ECActionMapping ( com.ibm.commerce.struts.ECActionMapping) is the WebSphere Commerce extension of the Struts ActionMapping class (org.apache.struts.action.ActionMapping) that allows custom configuration information to be passed to actions of the WebSphere Commerce Web application. These include both WebSphere Commerce-specific custom properties and arbitrary additional properties:
The https, authenticate, and credentialsAccepted properties are examples of WebSphere Commerce-specific custom properties.
(See Configuring the Web application for examples of setting these properties declaratively.)
Arbitrary additional properties can be passed to instances of the action classes based on the BaseAction class by setting the property named defaultProperties. Note: The defaultProperties property replaces the parameter attribute used in org.apache.struts.action.ActionMapping. In WebSphere Commerce, the latter is used to supply the name of the interface of the controller command to be used by an action.
To specify a mapping for an instance of the BaseAction class or its descendants, you must use or extend the ECActionMapping class.
Action forms
Action forms are a key view component that is used to transfer information between the view and the controller-model pair.
An ActionForm object is a Java (JavaBeans) representation of HTML form data. As such, it encapsulates form data for easy population and retrieval, supports form data validation, and is reusable.
Input data is transferred to ActionForm objects automatically by the Struts framework.
Beginning with version 1.1, Struts also supports dynamic action forms. These are built-in reusable ActionForm subclasses that can be configured using XML rather than explicitly creating an ActionForm class for each input form. Dynamic action forms allow developers to create action forms declaratively in the Struts configuration file without having to create an ActionForm class for each kind of HTML form or change the class every time the corresponding HTML form is altered.
The Struts framework creates an instance of the DynaActionForm class for each form-bean definition of type DynaActionForm (or its subtype) at run time.
Action forwards
Action forwards, properly considered to be a part of the controller, represent the next Web resource, typically an HTML or JSP page, in the control flow of the application. Returned by an action, an ActionForward object indicates where the request processor should forward the requestor.
ActionForward instances can be explicitly created in an Action class or preconfigured in the Struts configuration file (by means of forward elements within global-forward or action elements) and located at run time.
ECActionForward ( com.ibm.commerce.struts.ECActionForward) is the WebSphere Commerce extension of the Struts ActionForward class (org.apache.struts.action.ActionForward). Its distinguishing features are as follows:
Ability to specify extra, special-purpose forward properties such as resourceClassName
Ability to pass a collection of user-defined view properties (and their values) by means of a multi-valued property, named properties, in the form of an HTTP request query string (see Configuring the Web application for examples of setting this and preceding properties declaratively)
Ability to execute a view directly (see the ECActionForward class API documentation for details)
Struts configuration files
Both the action servlet and request processor rely on Struts configuration files for application-specific component information, allowing for a declarative, rather than programmatic, configuration of a Struts-based Web application.
The Struts configuration file is parsed during action servlet initialization, and a ModuleConfig object is created to represent it at run time.
An application can have a single Struts configuration file (struts-config.xml) or multiple Struts configuration files, defined in the Web application deployment descriptor (by means of init-param elements). By default, WebSphere Commerce provides multiple Struts configuration files per module, one for definitions, and the other for customizations and migration. Using multiple Struts configuration files is a "best practice", making parallel development easier and configuration less error- and conflict-prone.

XML FAQ

Posted by Anonymous | 3:43 PM | | 0 comments »

What is the main difference between XML and HTML?


Etisalat

DEVELOPER

bangalore

india

BLOGGER

SEX





1. Xml is case sensitive
2. In xml, there is no predefined tags such as
3. Each element must be closed.
4. Each attribute must be in enclosed by "".
5. Xml is for data, html is for visualization.
HTML is basically for the presentation of the dataIt Uses predefined tags for the presentation of the data.
XML is for describing the dataUser defined tags are used to describe the data structure and data.
XML
User definable tags
Content driven
End tags required for well formed documents
Quotes required around attributes values
Slash required in empty tags
HTML
Defined set of tags designed for web display
Format driven
End tags not required
Quotes not required
Slash not required
What parser would you use for searching a huge XML...
SAX, event based XML parser is probably what is needed to search huge file.
DOM store the whole content on memory which is in huge file is not good since it uses a lot of memory.
SAX is event based that handle XML elements when it find it.
What is a CDATA section in XML?
If we want to exclude some elements in XML document from parsing then we need to put those elements in CDATA.
So can we call Cdata as used for commenting in XML ?
CDATA in XML is the character data is is not parsed by the XML Processor.
If there is a section in the document that you do not want the XML processor to parse, then it can be enclosed in
What is DTD?
A Document Type Definition (DTD) defines the legal building blocks of an XML document.
It defines the document structure with a list of legal elements and attributes. DTD is Document Type Definition which gives the legal building blocks of an XML document.
The document which has a DTD associated with it is a Valid XML Document.
Dtd is document type definition used to building block and it is the set of the rule and document information.
Why is XML extensible?
The very purpose of XML is extension of the document.
XML specifies few and simple rules like
. The document should be a well formed xml.
. Must have a root element
. An element must have end tag
. Few other simple rules
Other than that, XML doesn’t levy heavy restriction like
. The document must contain 'n' tags, starting with xyz tag. (As html does, first tag should be html,header,body etc)
. No restriction on formatting of data (color, font etc.)
Thus xml is easily extensible and the proof is WML,mathXML,ebML,and cXML
What is the use of xml.onload property?
The "" element defines a script to be executed when the AppML application loads in a browser.Used in conjunction with the "script tag" form element.


What are the major features of XML?
• Properly nested
• Case sensitive
• Text based Compatible with the existing standards, Html,...
Where data is stored in XML?
Hi,XML data is stored as column data.
Data is stored in a data base (Depends on the machine it's running).
A main table is created in a relational database management system, wherein the main table has a column for storing as document in a native XML format One or more side tables are created in the relational database management system, wherein each side table has one or more columns that store one or more attributes extracted from the XML document for fast searching of the XML document.
Thereafter, the side tables are used to locate data in the main table.
How do you say XML is secured language on the information exchange over the network?
Actually it isn’t.
XML may be easy to write and even parse, but the use of XML as a medium of B2B data interchange is still bleak.
XML is used mainly for Application integration as it is just within the organization and where major security issues will not rise.
Also, with the ESB revolution and the whole industry striding towards SOA, XML is able to make its own impact.
But still, for B2B integrations, organizations prefer to use EDI ( electronic Data Interchange ) as compared to XML because EDI has withstood the test of time on security and also has tailor made templates for each industry.
XML is still in the amateur stage;
it’s still evolving. It will take a long time before we get to see XML taking up the place of EDI.




SQL Questions and Answers

Posted by Anonymous | 3:23 PM | | 0 comments »

Differences between oracle and mysql:

Etisalat

DEVELOPER

bangalore

india

BLOGGER

SQL







1.1.Some syntactic differences between Mysql and Oracle.
2.2.Oracle is not open source mysql is open source database.
3.3.Mysql does not have a language such as PL/SQL, but instead allows.
4.4.Mysql support auto increment function. Oracle does not support auto increment function.
5.5.Oracle support sub queries. Mysql does not support sub queries.
6.6.Mysql does not support views, trigger, indexing, sequence. Store procedure oracle support.
7.7.Oracle is generally use for much larger applications than mysql.
8.8.Oracle requires much more setup and tuning than mysql.

You can change and use it for getting Nth Highest Salary from Employee table as follows:

SELECT TOP 1 salary FROM (SELECT DISTINCT TOP n salary FROM employee ORDER BY salary DESC) aORDER BY salary
Using Self Joins: Example

The following query uses a self join to return the name of each employee along with the name of the employee's manager. (A WHERE clause is added to shorten the output.)
SELECT e1.last_name' works for 'e2.last_name "Employees and Their Managers" FROM employees e1, employees e2 WHERE e1.manager_id = e2.employee_id AND e1.last_name LIKE 'R%';
Employees and Their Managers
-------------------------------
Rajs works for Mourgos
Raphaely works for King
Rogers works for Kaufling
Russell works for King

The join condition for this query uses the aliases e1 and e2 for the sample table employees:e1.manager_id = e2.employee_id
Using Outer Joins: Examples

The following example uses a left outer join to return the names of all departments in the sample schema hr, even if no employees have been assigned to the departments:
SELECT d.department_id, e.last_name FROM departments d LEFT OUTER JOIN employees e ON d.department_id = e.department_id ORDER BY d.department_id;
DEPT_ID LAST_NAME
------------ -----------------
10 Whalen
20 Hartstein
20 Fay
30 Raphaely
...
250
260
270

Users familiar with the traditional Oracle outer joins syntax will recognize the same query in this form:
SELECT d.department_id, e.last_name FROM departments d, employees e WHERE d.department_id = e.department_id(+) ORDER BY d.department_id;

Oracle Corporation strongly recommends that you use the more flexible Oracle9i FROM clause join syntax shown in the former example.
The left outer join returns all departments, including those without any employees. The same statement with a right outer join returns all employees, including those not yet assigned to a department:
Note: The employee Zeuss was added to the employees table for these examples, and is not part of the sample data.
SELECT d.department_id, e.last_name
FROM departments d
RIGHT OUTER JOIN employees e
ON d.department_id = e.department_id
ORDER BY d.department_id;
DEPT_ID LAST_NAME
------------- -------------------------
...
110 Higgins
110 Gietz
.....Grant
.....Zeuss

It is not clear from this result whether employees Grant and Zeuss have department_id NULL, or whether their department_id is not in the departments table.
To determine this requires a full outer join:
SELECT d.department_id as d_dept_id, e.department_id as e_dept_id, e.last_name
FROM departments d
FULL OUTER JOIN employees e
ON d.department_id = e.department_id
ORDER BY d.department_id;
D_DEPT_ID E_DEPT_ID LAST_NAME
---------- ---------- -------------------------
...
110 110 Gietz
110 110 Higgins
...
260 270 Zweues
Because the column names in this example are the same in both tables in the join, you can also use the common column feature (the USING clause) of the join syntax, which coalesces the two matching columns department_id.
The output is the same as for the preceding example:
SELECT department_id AS d_e_dept_id, e.last_name
FROM departments d FULL OUTER JOIN employees e
USING (department_id) ORDER BY department_id;
D_E_DEPT_ID LAST_NAME
----------- -------------------------
...
110 Higgins
110 Gietz ...
260
270
.... Grant
.... Zeuss
What is a self join? Explain it with an example?
CREATE TABLE candytest
(kidId char(2), candycolor varchar(10) )
GO
INSERT INTO candytest SELECT 'K1', 'Yellow'
INSERT INTO candytest SELECT 'K1', 'Red'
INSERT INTO candytest SELECT 'K2', 'Red'
INSERT INTO candytest SELECT 'K2', 'Blue'
INSERT INTO candytest SELECT 'K3', 'White'
INSERT INTO candytest SELECT 'K3', 'Red'
INSERT INTO candytest SELECT 'K3', 'Yellow'
Go--
Now to find those kidid's which has both yellow and redcolored candies, we can write query as:
SELECT c1.kididFROM candytest AS c1 JOIN candytest AS c2ON c1.candycolor = 'Red' AND c2.candycolor = 'Yellow'AND c1.kidid = c2.kidid

Re: Table Has C1 And C2 Column If Exits any record in c1 then Update c2 record Otherwise insert new record in the C1 And C2 (Using Procedure)

select * from x;

C1 C2

----- ----------
1
2
3
4
5
6
7
8
9
10

1 create or replace procedure updt_x is
2 cnt number(4);
3 begin
4 select count(1) into cnt from x where c1 is not null;
5 if cnt > 0 then
6 update x
7 set c2=10;
8 else
9 insert into x
10 values(1,2);
11 end if;
12 commit;
13* end;
SQL> execute updt_x;
PL/SQL procedure successfully completed.
SQL> select * from x;
C1 C2
---------- ----------
1 10
2 10
3 10
4 10
5 10
6 10
7 10
8 10
9 10
10 10
10 rows selected.
SQL> delete from x;
10 rows deleted.
SQL> commit;
PL/SQL procedure successfully completed.
SQL> select * from x;
C1 C2
---------- ----------
1 2

What is the difference between Struts 1.0 and Struts 1.1

Etisalat

DEVELOPER

bangalore

india

BLOGGER

SEX






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.xml
4.Declarative exception handling
5.Dynamic ActionForms
6.Plug-ins
7.Multiple Application Modules
8.Nested Tags
9.The Struts Validator
10.Change to the ORO package
11.Change to Commons logging
12.Removal of Admin actions
13. Deprecation of the GenericDataSource

Struts 1.1 has method execute in action class where as Struts 1.0 contains performexecute() method

new concepts in struts1.1 are
1)changes to the web.xml file as well as Struts-config.xml
2)performExcecute() is replaced by execute() method
3)plug-ins added
4)RequestProcessor class..etc

The main differences are

1. In Action class Perform() method was replaced by execute() method.
2. DynaActionForms are added.
3. Tiles Concept is introduced.
4. We can write our own Controller by Inheriting RequestProcessor class. i.e., nothing but we can override the process() method of the RequestProcessor class.
Apart from these some updates in web.xml and Struts-Config.xml.
As per my point of view, from struts 1.1 it is recommended to use ActionMessages instead of ActionErrors , ActionMessage instead of ActionError and SaveMessages in place of saveErrors

Differences between Struts 1.1 and 1.2:-

1) Advised for replacement of ActionErrors with ActionMessages
2) org.apache.struts.Action statics: Use org.apache.struts.Global statics instead
3) Many utility methods previously found in org.apache.struts.utils.RequestUtils have been moved to org.apache.struts.taglibs.TagUtils or org.apache.struts.utils.ModuleUtils.
4) Introduction of MappingDispatchAction : A new standard Action that dispatches to a method named by the ActionMapping parameter.
5) Introduction of DigestingPlugIn - A new standard PlugIn that helps you create your own object graph in application scope. This is handy way to create business objects for Actions to call.
6) Addition of Action attributes - An Action attribute has been added to the html img tag, to match what's available on the html link tag now.
7) Additon of Module attribute - A new "module" attribute is available on the forward element as well as several of the core tags. This attribute allows you to specify another module by name (or "prefix") to create direct links between modules. The new module attribute is preferred to the contextRelative attribute and can often be used in lieu of a "SwitchAction".

The main differences are

1. In Action class Perform() method was replaced by execute() method.
2. DynaActionForms are added.
3. Tiles Concept is introduced.
4. We can write our own Controller by Inheriting RequestProcessor class. i.e., nothing but we can override the process() method of the RequestProcessor class.
-------------------------------------------------------------------------------------------------------

action
org.apache.struts.action.ActionServlet

config
/WEB-INF/struts-config.xml,/WEB-INF/struts-config-wfm.xml,/WEB-INF/struts-config-soh.xml,/WEB-INF/struts-config-pay.xml

Difference Between java bean And POJO

Posted by Anonymous | 3:17 PM | | 0 comments »


Difference Between java bean And POJO:

Etisalat

DEVELOPER

bangalore

india

BLOGGER

SEX






The Java-Beanness of a POJO is that its public attributes are all accessed via getters and setters that conform to the JavaBeans conventions.
e.g.
private String foo;
public String getFoo(){...}
public void setFoo(String foo){...};

Additionally, true JavaBeans must implement Serializable and have a no-argument constructor.
POJOs don't have these restrictions.

Core Basics of Java FAQ

Posted by Anonymous | 4:55 PM | | 0 comments »

Core Java basics


Etisalat

DEVELOPER

bangalore

india

BLOGGER

SEX





Can I have multiple main methods in the same class? »
No the program fails to compile. The compiler says that the main method is already defined in the class.

Can an application have multiple classes having main method? »
Yes it is possible. While starting the application we mention the class name to be run. The JVM will look for the Main method only in the class whose name you have mentioned. Hence there is not conflict amongst the multiple classes having main method.

How can one prove that the array is not null but empty? »
Print args.length. It will print 0. That means it is empty. But if it would have been null then it would have thrown a NullPointerException on attempting to print args.length.

What if I do not provide the String array as the argument to the method? »Program compiles but throws a runtime error “NoSuchMethodError”.

What if I write static public void instead of public static void? »
Program compiles and runs properly.

What if the static modifier is removed from the signature of the main method? »
Program compiles. But at runtime throws an error “NoSuchMethodError”.

What if the main method is declared as private? »
The program compiles properly but at runtime it will give “Main method not public.” message.A compilation unit is a Java source code file.

What is the purpose of garbage collection? »
The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources may be reclaimed and reused.

How are this and super used? »
this is used to refer to the current object instance. super is used to refer to the variables and methods of the superclass of the current object instance.

What interface must an object implement before it can be written to a stream as an object? »
An object must implement the Serializable or Externalizable interface before it can be written to a stream as an object.

What is your platform’s default character encoding? »
If you are running Java on English Windows platforms, it is probably Cp1252. If you are running Java on English Solaris platforms, it is most likely 8859_1.

What happens when you add a double value to a String? »
The result is a String object.162.

What is the difference between the File and RandomAccessFile classes? »
The File class encapsulates the files and directories of the local file system. The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.

What classes of exceptions may be thrown by a throw statement? »
A throw statement may throw any expression that may be assigned to the Throwable type.The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements.

If an object is garbage collected, can it become reachable again? »
Once an object is garbage collected, it ceases to exist. It can no longer become reachable again.

What are the legal operands of the instanceof operator? »
The left operand is an object reference or null value and the right operand is a class, interface, or array type.

Why are the methods of the Math class static? »
So they can be invoked as if they are a mathematical code library.

How is it possible for two String objects with identical values not to be equal under the == operator? »
The == operator compares two objects to determine if they are the same object in memory. It is possible for two String objects to have the same value, but located indifferent areas of memory.

What is the relationship between a method’s throws clause and the exceptions that can be thrown during the method’s execution? »
A method’s throws clause must declare any checked exceptions that are not caught within the body of the method.Under what conditions is an object’s finalize() method invoked by the garbage collector? »The garbage collector invokes an object’s finalize() method when it detects that the object has become unreachable.

What is the difference between a field variable and a local variable? »
A field variable is a variable that is declared as a member of a class. A local variable is a variable that is declared local to a method.

What class allows you to read objects directly from a stream? »
The ObjectInputStream class supports the reading of objects from input streams.

What class of exceptions are generated by the Java run-time system? »The Java runtime system generates RuntimeException and Error exceptions.

What happens when you invoke a thread’s interrupt method while it is sleeping or waiting? »
When a task’s interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an InterruptedException is thrown.

Which non-Unicode letter characters may be used as the first character of an identifier? »
The non-Unicode letter characters $ and _ may appear as the first character of an identifier

If a method is declared as protected, where may the method be accessed? »
A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

Which class is the immediate superclass of the Container class? »
ComponentCan an exception be rethrown? »Yes, an exception can be rethrown.

What is the difference between static and non-static variables? »
A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.

Name the eight primitive Java types. »
The eight primitive types are byte, char, short, int, long, float, double, and boolean.

What happens when a thread cannot acquire a lock on an object? »
If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object’s lock, it enters the waiting state until the lock becomes available.

How is rounding performed under integer division? »
The fractional part of the result is truncated. This is known as rounding toward zero

Can an object be garbage collected while it is still reachable? »
A reachable object cannot be garbage collected. Only unreachable objects may be garbage collected.

What is an object’s lock and which objects have locks? »
An object’s lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object’s lock. All objects and classes have locks. A class’s lock is acquired on the class’s Class object.

If a variable is declared as private, where may the variable be accessed? »
A private variable may only be accessed within the class in which it is declared.

Can a Byte object be cast to a double value? »No, an object cannot be cast to a primitive value.What value does read() return when it has reached the end of a file? »The read() method returns -1 when it has reached the end of a file.The high-level thread states are ready, running, waiting, and dead.

What method is invoked to cause an object to begin executing as a separate thread? »
The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread.The = operator is right associative.

What invokes a thread’s run() method? »
After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread’s run() method when the thread is initially executed.

When a thread is created and started, what is its initial state? »
A thread is in the ready state after it has been created and started.

To what value is a variable of the String type automatically initialized? »
The default value of a String type is null.

When a thread blocks on I/O, what state does it enter? »
A thread enters the waiting state when it blocks on I/O.

What value does readLine() return when it has reached the end of a file? »
The readLine() method returns null when it has reached the end of a file.

What is the difference between preemptive scheduling and time slicing? »
Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on […]

What is synchronization and why is it important? »
With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object’s value. This often leads to significant errors.

How are Observer and Observable used? »
Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.

Struts part I

Posted by Anonymous | 3:42 PM | 0 comments »

Struts Part I

Etisalat

DEVELOPER

bangalore

india

BLOGGER

APACHE





Q.What is Struts?

Struts is a java framework based on Model 2 architecture of JSP or popularly called Model-View-Controller architecture. It provides a controller for this architecture.
Q.What is Tiles-def.xml & validation.xml in Struts?
tiles-def.xmltiles-def.xml is used as a configuration file for an appliction during tiles development You can define the layout / header / footer / body content for your View.Eg:

Content goes here


2. validation.xml
The validation.xml file is used to declare sets of validations that should be applied to Form Beans.Each Form Bean you want to validate has its own definition in this fileInside that definition, you specify the validations you want to apply to the Form Bean'sfields.
Eg:
target="_top">
form-validation
3. Resourcebundle.properties
Instead of having hard-coded error messages in the framework, Struts Validator allows you to specify a key to a message in the ApplicationResources.properties (or resourcebundle.properties) file that should be returned if a validation fails. Eg:In ApplicationResources.propertieserrors.registrationForm.name={0} Is an invalid name.
In theregistrationForm.jsp

Output(in red color) :
abc Is an invalid name ________________
1. Purpose of tiles-def.xml file is used to in the design face of the webpage. For example in the webpage "top or bottom or left is fixed" center might be dynamically chaged.It is used for the easy design of the web sites. Reusability
2. resourcebundle.properties file is used for lot of purpose. One of its purpose is internationalization. We can make our page to view on any language. It is independent of it. Just based on the browser setting it selects the language and it displayed as you mentioned in the resourcebundle.properties file.
3. Validation rule.xml is used to put all the validation of the front-end in the validationrule.xml. So it verifies. If the same rule is applied in more than one page. No need to write the code once again in each page.Use validation to chek the errors in forms.
tiles-def.xml - is required if your application incorporates the tiles framework in the "View" part of MVC. Generally we used to have a traditional JSP's (Which contgains HTML & java scriplets) are used in view.
But Tiles is an advanced (mode or less ) implementation of frames used in HTML. We used to define the frames in HTML to seperate the header html, footer html, menu or left tree and body.html to reuse the contents.
Hence in the same way, Tiles are defined to reuse the jsp's in struts like architectures, and we can define the jsp's which all are to be display at runtime, by providing the jsp names at runtime.
To incorporate this we need tile-def.xml and the Class generally which extends RequestProcessor should extend TilesRequestProcessor.resourcebundle.properties -- It is to incorporate i18n (internationalization) in View part of MVC.validation.xml - This file is responsible for business validations carried at server side before processing the request actually.
It reduces the complexity in writing _JavaScript validations, and in this way, we can hide the validations from the user, in View of MVC.
1.The Tiles Framework is an advanced version of that comes bundled with the Struts Webapp framework. Its purpose is reduce the duplication between jsp pages as well as make layouts flexible and easy to maintain.
It integrates with Struts using the concept of named views or definitions. 2.Resourcebundle.properties is used to maintian all the strings that are used in the application and their corresponding equalents in different desiredlanguages. All the strings/labels in the application using Struts will get it labels from this file only depending on locale.
This is an i18n implementation of struts
3. This validation.xml configuration file defines which validation routines that is used to validate Form Beans. You can define validation logic for anynumber of Form Beans in this configuration file.
Inside that definition, you specify the validationsyou want to apply to the Form Bean's fields.
The definitions in this file use the logical names of Form Beans from the struts-config.xml file along with the logical names of validation routines from the validator-rules.xml file to tie the two together.

Q.What is DispatchAction?
DispatchAction is specialized child of Struts Action class. It combines or group the methods that can further access the bussiness logic at a single place. The method can be anyone from CRUD [Create,Retrieve,Update or Delete] or it can be security check one like authenticate user etc.
This class apart from having thread-safe execute method also can have user-defined methods.In struts-config.xml files following changes are required for Dispatch action to work:
parameter ="task" scope = "request" validate = "false"
input = "/index.jsp">


If above is your struts-config.xml file structure and LoginAction extends DispatchAction instead of normal Action class. And assuming [keep assuming] your LoginAction class have method named authenticateUser, then in your login.jsp add any hidden parameter called task with value as your method name and on submit of that page following will be the url:
Thus if we try to combine the last part of this puzzle we get the climax at struts-config.xml file's action-mapping tag described above.
The parameter property of tag have the task as it's value pointing to task variable in the request having it's value as authenticateUserhence the framework search in the LoginAction a method called authenticateUser through reflection and forwards the execution flow to it.
This is all folks, the briallancy of Struts framework. Note DispatchAction class is included in 1.1 version.
Q.How to call ejb from Struts?
We can call EJB from struts by using the service locator design pattern or by using initial context with create home object and getting return remote reference object.Q.In struts how I can validate the values filled into the text boxes or else using DynaValidatorForm, without using JavaScript.
Actually with JavaScript it is working perfect but not without JavaScript, and I want without JavaScript?
Using the validate() method of the ActionForm class, the values filled in the form will be validated in the case there is no JavaScript for validating the form.

Q.What is the difference between ActionErrors and ActionMessages?
There is no difference between these two classes. All the behavior of ActionErrors was copied into ActionMessages and vice versa. This was done in the attempt to clearly signal that these classes can be used to pass any kind of messages from the controller to the view -- where as errors being only one kind of message.
The difference between saveErrors(...) and saveMessages(...) is simply the attribute name under which the ActionMessages object is stored, providing two convenient default locations for storing controller messages for use by the view.
If you look more closely at the html:errors and html:messages tags, you can actually use them to get an ActionMessages object from any arbitrary attribute name in any scope.

Q.What is the various Struts tag libraries?

The Struts distribution includes four tag libraries for the JSP framework (in struts-config.xml) :* Bean tag library [ struts-bean.tld ] : Contains tags for accessing JavaBeans and their properties. Developers can also define new beans and set properties* HTML tag library [ struts-html.tld ] :
Contains tags to output standard HTML, including forms, textfields, checkboxes, radio buttons* Logic tag library [ struts-logic.tld ] :
Contains tags for generating conditional output, iteration capabilities and flow management* Tiles or Template tag library [ struts-tiles.tld / struts-template.tld ] :
For tiles implementation* Nested tag library [ struts-nested.tld ] : allows the use of nested beans.
The libraries are designed to:* Facilitate the separation of presentation and business logic.* dynamically generate Web pages.
* Implement the flow of control to and from the ActionServlet.
Q.What is the difference between Struts 1.0 and 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.xml
4.Declarative exception handling
5.Dynamic ActionForms
6.Plug-ins
7.Multiple Application Modules
8.Nested Tags
9.The Struts Validator
10.Change to the ORO package
11.Change to Commons logging
12.Removal of Admin actions
13. Deprecation of the GenericDataSource.
Q.What are the core classes of struts?

The core classes of struts are ActionForm, Action, ActionMapping, ActionForward etc.

Q.In struts what happens if made any changes in actionservlet?

The ActionServlet plays the role of controller which is responsible for handling the request and selecting the correct Application Module and storing ApplicationConfig and MessageResource bundle in the request object. If we modify the ActionServlet the Controller may or may not work what happens that depends on your modification, You have not specify whether you want to create your own custom ActionServlet by extending ActionServlet and overriding the methods in it or what exactly you want to modify.
Q.What part of MVC does Struts represent ?

Struts is mainly famous for its Action Controller - which is nothing but the CONTROLLER part of MVC Pattern.
To add up, Struts is the framework which started mainly using the MVC-2 Pattern where in the Business logic is STRICTLY SEPARATED from the Presentation logic
Q.How you will handle errors and exceptions using Struts?

Struts exception handling can be done by two ways:
1. Declarative (using struts features via struts-config.xml) this makes coding in the Action class very simple since the execute method declares throws Exception we don't need a try-catch block. Struts saves the exception using one of its global constants.
You may use the field Globals.EXCEPTION_KEY to retrieve it from the request object.
2. Programmatic (using the usual try-catch exception handling in Action Class).


Q.What are the Important Components of Struts?

Struts Configuration File
ActionServlet
RequestProcessor
ActionForm
Action
ActionFroward
ActionMapping
ActionErrors
Q.How you will save the data across different pages for a particular client request using Struts ?

Several ways. The similar to the ways session tracking is enabled.
Using cookies, URL-rewriting, SSLSession, and possibility threw in the database.

Q.Does Struts provide support for Validator & Tiles by default ?

NO.
Struts does not provide default support for Validator and Tiles. Additional plugins are required for the purpose
Q.Is there any way to put my custom name to LIB folder which I am going to place in WEB-INF folder of struts application?

No,
not possible because web servers are strictly denoting the directory structure and names .so that it will recognize that lib is a directory having library files
Q.Can I use bc4j with spring framework no it is not possible

Q.In struts, if any changes are made to before the request reaches to actionservlet, where you do the changes?

In struts the first to receive the request is Actionservlet. So, there is no chance for you to make changes before
Q.What are the drawbacks of Struts?

In struts , their is no facility of backward flow. Suppose we are in page 1 and when we submit it calls action mapping page2.
Their may be lot of variable stored in session , which is available to page2. Now we wish to go page1 from page 2, for this we have to call the action mapping of page1. But struts flow is always in forward direction.
So when we call page 1, values stored in session never get reversed. So it reduces the performance.
To resolve this problem of struts, their is a framework called Web Flow Navigation Manager(WFNM) of Sourgeforge.net.
This framework can be integrated with struts.
Q.How can we work struts on Eclipse? What is the best plug-in for this?

Eclipse work bench provides option to any web project. Building struts application becomes very easy with the GUI provided and drag drop feature of struts-config file. The best plug-in available is My-eclipse .
Q.What is the difference between a normal servlet and action servlet?
Both a normal servlet and action servlet are same, which extend HttpServlet and implement the servlet lifecycle methods..

Q.What is Action Class. What are the methods in Action class?

An Action is an adapter between the contents of an incoming HTTP request and the corresponding business logic that should be executed to process this request. The controller (RequestProcessor) will select an appropriate Action for each request, create an instance (if necessary), and call the execute method.
Actions must be programmed in a thread-safe manner, because the controller will share the same instance for multiple simultaneous requests.
This means you should design with the following items in mind: Instance and static variables MUST NOT be used to store information related to the state of a particular request.
They MAY be used to share global resources across requests for the same action.
Access to other resources (JavaBeans, session variables, etc.) MUST be synchronized if those resources require protection. (Generally, however, resource classes should be designed to provide their own protection where necessary. When an Action instance is first created, the controller will call setServlet with a non-null argument to identify the servlet instance to which this Action is attached. When the servlet is to be shut down (or restarted), the setServlet method will be called with a null argument, which can be used to clean up any allocated resources in use by this Action.
Q.What is Action Class? What are the methods in Action class?

An Action class is some thing like an adapter between the contents of an incoming HTTP request and the corresponding business logic that should be executed to process this request. The controller (RequestProcessor) will select an appropriate Action for each request, create an instance (if necessary), and call the execute method.
Struts Action class is a unit of logic. It is where a call to business function is made. In short the Action class acts like a bridge between client side(user action) and business operation(on server. Some of the important methods of Action class are, execute()generateToken() resetToken() getServlet()
Q.What is the use of ActionForm class, Describe it's Life Cycle?

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 & Business Tier.
Life Cycle :
1. Request received by Controller
2. Create or recycle ActionForm
3. Call reset()
4. store ActionForm in proper scope
5. populate ActionForm from Request
6. Validate the ActionForm
7. If errors found then forward back to input attribute page(configured in Action mapping in struts-config.xml) with ActionForm in scope.
If no errors found then call execute() with the ActionForm.

Q.In struts why we use jsp as presentation layer? can we use servlet as presentation layer?

We can separate the business logic from presentation logic2.
It facilitates to write the java code inside a html environment if we use servlets then we need to write the html tags inside out.write() number of times.
it is not possible in all cases and it combines the businesslogic and presentation logic which reduces security
Q. Explain about token feature in Struts?

Use the Action Token methods to prevent duplicate submits:
There are methods built into the Struts action to generate one-use tokens.
A token is placed in the session when a form is populated and also into the HTML form as a hidden property. When the form is returned, the token is validated.
If validation fails, then the form has already been submitted, and the user can be apprised.

ul>
  • saveToken(request)
  • on the return trip,
  • isTokenValid(request)
  • resetToken(request)

    Q.What is the difference between ActionForm and DynaActionForm?

  • # The DynaActionForm bloats up the Struts config file with the xml based definition. This gets annoying as the Struts Config file grow larger.
    # The DynaActionForm is not strongly typed as the ActionForm. This means there is no compile time checking for the form fields. Detecting them at runtime is painful and makes you go through redeployment.
    # ActionForm can be cleanly organized in packages as against the flat organization in the Struts Config file.
    # ActionForm were designed to act as a Firewall between HTTP and the Action classes, i.e. isolate and encapsulate the HTTP request parameters from direct use in Actions. With DynaActionForm, the property access is no different than using request.getParameter( .. ).
    # DynaActionForm construction at runtime requires a lot of Java Reflection (Introspection) machinery that can be avoided.
    # Time savings from DynaActionForm is insignificant. It doesn’t t take long for today s IDEs to generate getters and setters for the ActionForm attributes. (Let us say that you made a silly typo in accessing the DynaActionForm properties in the Action instance. It takes less time to generate the getters and setters in the IDE than fixing your Action code and redeploying your web application)

    Q.Explain Struts navigation flow?
    Struts Navigation flow.
    1) A request is made from previously displayed view.
    2) The request reaches the ActionServlet which acts as the controller.
    The ActionServlet Lookup the requested URI in an XML file (Struts-Config.xml) and determines the name of the Action class that has to perform the requested business logic.
    3)The Action Class performs its logic on the Model Components associated with the Application.
    4) Once The Action has been completed its processing it returns the control to the Action Servlet.
    As part of its return the Action Class provides a key to determine where the results should be forwarded for presentation.
    5)The request is complete when the Action Servlet responds by forwarding the request to the view, and this view represents the result of the action.

    free counters
    Your Ad Here

    Cross Rates Powered by Forex Pros - The Forex Trading Portal.
    java.sun.com jobs etisalat actress hot sex
    Bangalore, 04 March 2008, UAE Telecoms Gaint founds ‘technologia’ in Bangalore to create continuous stream of new innovations. Affordable Website Design
    Free Search Engine Submission
    Free Search Engine Submission
    Submit Your Site To The Web's Top 50 Search Engines for Free! BigDirectory.org - free url submission, online website directory National Directory Free Web Directory Submission - Dotster Directory Link Popularity Building
    We offers advanced Link Popularity Services for small to large static, dynamic and eCommerce websites.
    http://www.links-builder.com
    India Search Engine and Web Directory Superblog Directory
    HOT SEX,NUDE TECHNOLOGIAWORLD SQL JAVA SUN BEA IBM HCL SATYAM TCS CHIRANJEEVI CHIRU PAWAN HANSIKA SANGAVI SNEHA TAMIL SEX MALLU MASALA