james-gosling father of the Java



James A. Gosling, O.C., Ph.D. (born May 19, 1955 near Calgary, Alberta, Canada) is a software developer, best known as the father of the Java programming language.

Education and career

In 1977, James Gosling received a B.Sc in Computer Science from the University of Calgary. In 1983, he earned a Ph.D in Computer Science from Carnegie Mellon University, and his doctoral thesis was titled "The Algebraic Manipulation of Constraints". While working towards his doctorate, he wrote a version of emacs (gosmacs), and before joining Sun Microsystems he built a multi-processor version of Unix[1] while at Carnegie Mellon University, as well as several compilers and mail systems.

Since 1984, Gosling has been with Sun Microsystems, and is generally known best as the father of the Java programming language

A software developer is a person or organization concerned with facets of the software development process wider than design and coding, a somewhat broader scope of computer programming or a specialty of project managing including some aspects of software product management. This person may contribute to the overview of the project on the application level rather than component level or individual programming tasks. Software developers are often still guided by lead programmers but also encompasses the class of freelance software developers.

History of Java and Programmer James Gosling

Java is a programming language and environment invented by James Gosling and others in 1994. Java was originaly named Oak and was developed as a part of the Green project at the Sun Company.
James Gosling, widely regarded as the father of Java technology, has been hard at work helping Sun Microsystems with its efforts to open source Sun's Java SE (JDK) and Java ME implementations. The Java EE implementation has been open sourced for over a year as Project GlassFish. Part 1 of the interview took place shortly before Sun's official announcement, and we spoke again just afterward.

Today, with technology such a part of our daily lives, we take it for granted that we can be connected and access applications and content anywhere, anytime. Because of Java, we expect digital devices to be smarter, more functional, and way more entertaining.

In the early 90s, extending the power of network computing to the activities of everyday life was a radical vision. In 1991, a small group of Sun engineers called the "Green Team" believed that the next wave in computing was the union of digital consumer devices and computers. Led by James Gosling, the team worked around the clock and created the programming language that would revolutionize our world – Java.

The Green Team demonstrated their new language with an interactive, handheld home-entertainment controller that was originally targeted at the digital cable television industry. Unfortunately, the concept was much too advanced for the them at the time. But it was just right for the Internet, which was just starting to take off. In 1995, the team announced that the Netscape Navigator Internet browser would incorporate Java technology.

Today, Java not only permeates the Internet, but also is the invisible force behind many of the applications and devises that power our day-to-day lives. From mobile phones to handheld devises, games and navigation systems to e-business solutions, Java is everywhere!

Servlet LifeCycle / Life Cycle of a Servlet


Servlet: Servlets are server side java components which provide a powerful mechanism for developing server side java programs. Servlets are mainly used to develop Web-based applications.

Servlet lifecycle

Servlet lifecycle is handled by the servlet container. Servlets are managed components and are managed by web(servlet) container. Servlet life cycle management is the most important responsibility of web container. A servlet is managed through a well defined life cycle that defines how it is loaded, instantiated ad initialized, handles requests from clients and how it is taken out of service.

Syntax:

public void init(ServletConfig config) throws ServletException
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException
public void destroy()

The servlet life cycle consists of four steps:

1. Instantiation
2. Initialization(init())
3. request handling (service())
4. end of service (destroy())

Instantiation (Loading the Servlet)


During this step, web(servlet) container loads the servlet class and creates a new instance of the servlet. The container can create a servlet instance at container startup or it can delay it until the servlet is needed to service a request.


Initialization


During initialization stage of the Servlet life cycle, the web(servlet) container initializes the servlet instance by calling the init() method. The container passes an object implementing the ServletConfig interface via the init() method. This configuration object allows the servlet to access name-value initialization parameters from the web application’s deployment descriptor web.xml file. The container guarantees that the init() method will be called before the service() method is called.


The init() method is typically used to perform servlet initialization, creating or loading objects that are used by the servlet in the handling of its requests. The init() method is commonly used to perform one time activity that is it will be called only once in the life time of the servlet. One of the most common use of init() method is to setup the database connection or connection pool.

Request handling


After a servlet is properly initialized, it is ready to handle the client requests. If the container has a request for the servlet, it calls the servlet instance’s service() method. The request and response information is wrapped in ServletRequest and ServletResponse objects respectively, which are then passed to the servlet`s service() method. In the case of an HTTP request, the objects provided by the container are of types HttpServletRequest and HttpServletResponse.


Service() method is responsible for processing the incoming requests and generating the response. The service phase of the Servlet life cycle represents all interactions with requests until the Servlet is destroyed. The Servlet interface matches the service phase of the Servlet life cycle to the service() method. The service() method of a Servlet is invoked once per a request and is responsible for generating the response to that request.


The Servlet specification defines the service() method to take two parameters: a javax.servlet.ServletRequest and a javax.servlet.ServletResponse object. These two objects represent a client`s request for the dynamic resource and the Servlet`s response to the client.

By default a Servlet is multi-threaded, meaning that typically only one instance of a Servlet1 is loaded by a JSP container at any given time. Initialization is done once, and each request after that is handled concurrently2 by threads executing the Servlet`s service() method.

End of service() method


When the servlet container determines that a servlet should be removed from service, it calls the destroy () method of the Servlet instance to allow the servlet to release any resources it is using. The servlet container can destroy a servlet because it wants to conserve some memory or server itself is shutting down.

Sample Covering Letter for Java Professionals

Dear HR,

This is in response to your advertisement for the position of "Java Developers".

I am T.Neelakandan, very interested to make a good career with your esteemed organization.

Below are my brief details for your consideration. My detailed resume can be found as attachment.

Experience: 4 Years of Software Analysis, Design, Development and Testing experience in JAVA, J2EE

Current Company: Mpro Technolocies Pvt Ltd, Bangalore

Current Role: Senior Java Developer

Proficient in : JAVA, J2EE, EJB, JSP, SERVLETS, STRUTS, HIBERNATE, WEBLOGIC, WEBSPHERE, ORACLEjavascript:void(0)

Certifications: SCJP (Sun Certified Java Professional), CSQA (Certified Software Quality Analyst)

Qualification: B.Tech, Computer Science (2004) with 83.0 %

Current Location : Bangalore

Willing to Relocate: YES

Current CTC: 6 lacs per annum

Expected CTC: Negotiable

Notice Period: 1 Month

Please consider my application for any suitable opportunities in Java Development.

Thanks & Regards,
T.neelakandan
Mobile: (91) 9999999999
Email: ncs.neelu@gmail.com

Sun Certified Web Component Developer (SCWCD)

Sun Certified Web Component Developer (SCWCD)



Sun Certified Web Component Developer (SCWCD) Overview

This certification is for developers specializing in the application of JavaServer Pages and servlet technologies used to present Web services and dynamic Web content.

To achieve this certification, candidates must successfully complete one exam. Prior to attempting certification, candidates must be certified as a Sun Certified Programmer (SCJP), any edition.

Follow links for detailed information, exam objectives and to purchase:

- Sun Certified Web Component Developer for the Java Platform, Enterprise Edition 5 (CX-310-083)
- Upgrade Exam: Sun Certified Web Component Developer for the Java Platform, Enterprise Edition 5 (CX-310-084)

Certification Preparation

Sun is pleased to take the guesswork out of preparing for certification. Learn about prerequisites, practice exams and recommended training options to help you achieve this certification. » More

Certification exams and training products must be purchased in the country where you reside. For inquiries outside this country, please select your local training office. » More

SCWCD 1.4 Objectives
Section 1: The Servlet Technology Model

1. For each of the HTTP Methods (such as GET, POST, HEAD, and so on) describe the purpose of the method and the technical characteristics of the HTTP Method protocol, list triggers that might cause a Client (usually a Web browser) to use the method; and identify the HttpServlet method that corresponds to the HTTP Method.
2. Using the HttpServletRequest interface, write code to retrieve HTML form parameters from the request, retrieve HTTP request header information, or retrieve cookies from the request.
3. Using the HttpServletResponse interface, write code to set an HTTP response header, set the content type of the response, acquire a text stream for the response, acquire a binary stream for the response, redirect an HTTP request to another URL, or add cookies to the response.
4. Describe the purpose and event sequence of the servlet life cycle: (1) servlet class loading, (2) servlet instantiation, (3) call the init method, (4) call the service method, and (5) call destroy method.

Section 2: The Structure and Deployment of Web Applications

1. Construct the file and directory structure of a Web Application that may contain (a) static content, (b) JSP pages, (c) servlet classes, (d) the deployment descriptor, (e) tag libraries, (d) JAR files, and (e) Java class files; and describe how to protect resource files from HTTP access.
2. Describe the purpose and semantics of the deployment descriptor.
3. Construct the correct structure of the deployment descriptor.
4. Explain the purpose of a WAR file and describe the contents of a WAR file, how one may be constructed.

Section 3: The Web Container Model

1. For the ServletContext initialization parameters: write servlet code to access initialization parameters; and create the deployment descriptor elements for declaring initialization parameters.
2. For the fundamental servlet attribute scopes (request, session, and context): write servlet code to add, retrieve, and remove attributes; given a usage scenario, identify the proper scope for an attribute; and identify multi-threading issues associated with each scope.
3. Describe the Web container request processing model; write and configure a filter; create a request or response wrapper; and given a design problem, describe how to apply a filter or a wrapper.
4. Describe the Web container life cycle event model for requests, sessions, and web applications;create and configure listener classes for each scope life cycle; create and configure scope attribute listener classes; and given a scenario, identify the proper attribute listener to use.
5. Describe the RequestDispatcher mechanism; write servlet code to create a request dispatcher; write servlet code to forward or include the target resource; and identify and describe the additional request-scoped attributes provided by the container to the target resource.

Section 4: Session Management

1. Write servlet code to store objects into a session object and retrieve objects from a session object.
2. Given a scenario describe the APIs used to access the session object, explain when the session object was created, and describe the mechanisms used to destroy the session object, and when it was destroyed.
3. Using session listeners, write code to respond to an event when an object is added to a session, and write code to respond to an event when a session object migrates from one VM to another.
4. Given a scenario, describe which session management mechanism the Web container could employ, how cookies might be used to manage sessions, how URL rewriting might be used to manage sessions, and write servlet code to perform URL rewriting.

Section 5: Web Application Security

1. Based on the servlet specification, compare and contrast the following security mechanisms: (a) authentication, (b) authorization, (c) data integrity, and (d) confidentiality.
2. In the deployment descriptor, declare a security constraint, a Web resource, the transport guarantee, the login configuration, and a security role.
3. Compare and contrast the authentication types (BASIC, DIGEST, FORM, and CLIENT-CERT); describe how the type works; and given a scenario, select an appropriate type.

Section 6: The JavaServer Pages (JSP) Technology Model

1. Identify, describe, or write the JSP code for the following elements: (a) template text, (b) scripting elements (comments, directives, declarations, scriptlets, and expressions), (c) standard and custom actions, and (d) expression language elements.
2. Write JSP code that uses the directives: (a) 'page' (with attributes 'import', 'session', 'contentType', and 'isELIgnored'), (b) 'include', and (c) 'taglib'.
3. Write a JSP Document (XML-based document) that uses the correct syntax.
4. Describe the purpose and event sequence of the JSP page life cycle: (1) JSP page translation, (2) JSP page compilation, (3) load class, (4) create instance, (5) call the jspInit method, (6) call the _jspService method, and (7) call the jspDestroy method.
5. Given a design goal, write JSP code using the appropriate implicit objects: (a) request, (b) response, (c) out, (d) session, (e) config, (f) application, (g) page, (h) pageContext, and (i) exception.
6. Configure the deployment descriptor to declare one or more tag libraries, deactivate the evaluation language, and deactivate the scripting language. 6.7Given a specific design goal for including a JSP segment in another page, write the JSP code that uses the most appropriate inclusion mechanism (the include directive or the jsp:include standard action).

Section 7: Building JSP Pages Using the Expression Language (EL)

1. Given a scenario, write EL code that accesses the following implicit variables including pageScope, requestScope, sessionScope, and applicationScope, param and paramValues, header and headerValues, cookie, initParam and pageContext.
2. Given a scenario, write EL code that uses the following operators: property access (the . operator), collection access (the [] operator).
3. Given a scenario, write EL code that uses the following operators: aritmetic operators, relational operators, and logical operators.
4. Given a scenario, write EL code that uses a function; write code for an EL function; and configure the EL function in a tag library descriptor.

Section 8: Building JSP Pages Using Standard Actions

1. Given a design goal, create a code snippet using the following standard actions: jsp:useBean (with attributes: 'id', 'scope', 'type', and 'class'), jsp:getProperty, and jsp:setProperty (with all attribute combinations).
2. Given a design goal, create a code snippet using the following standard actions: jsp:include, jsp:forward, and jsp:param.

Section 9: Building JSP Pages Using Tag Libraries

1. For a custom tag library or a library of Tag Files, create the 'taglib' directive for a JSP page.
2. Given a design goal, create the custom tag structure in a JSP page to support that goal.
3. Given a design goal, use an appropriate JSP Standard Tag Library (JSTL v1.1) tag from the "core" tag library.

Section 10: Building a Custom Tag Library

1. Describe the semantics of the "Classic" custom tag event model when each event method (doStartTag, doAfterBody, and doEndTag) is executed, and explain what the return value for each event method means; and write a tag handler class.
2. Using the PageContext API, write tag handler code to access the JSP implicit variables and access web application attributes.
3. Given a scenario, write tag handler code to access the parent tag and an arbitrary tag ancestor.
4. Describe the semantics of the "Simple" custom tag event model when the event method (doTag) is executed; write a tag handler class; and explain the constraints on the JSP content within the tag.
5. Describe the semantics of the Tag File model; describe the web application structure for tag files; write a tag file; and explain the constraints on the JSP content in the body of the tag.

Section 11: J2EE Patterns

1. Given a scenario description with a list of issues, select a pattern that would solve the issues. The list of patterns you must know are: Intercepting Filter, Model-View-Controller, Front Controller, Service Locator, Business Delegate, and Transfer Object.
2. Match design patterns with statements describing potential benefits that accrue from the use of the pattern, for any of the following patterns: Intercepting Filter, Model-View-Controller, Front Controller, Service Locator, Business Delegate, and Transfer Object.

pepsi lovers

JDBC

What is JDBC?
JDBC is a layer of abstraction that allows users to choose between databases. It allows you to change to a different database engine and to write to a single API. JDBC allows you to write database applications in Java without having to concern yourself with the underlying details of a particular database.

What is JDBC Driver interface?
The JDBC Driver interface provides vendor-specific implementations of the abstract classes provided by the JDBC API. Each vendors driver must provide implementations of the java.sql.Connection,Statement,PreparedStatement, CallableStatement, ResultSet and Driver.

What are the common tasks of JDBC?
Create an instance of a JDBC driver or load JDBC drivers through jdbc.drivers
Register a driver
Specify a database
Open a database connection
Submit a query
Receive results

What packages are used by JDBC?
There are 8 packages: java.sql.Driver, Connection,Statement, PreparedStatement, CallableStatement, ResultSet, ResultSetMetaData, DatabaseMetaData.

What are the flow statements of JDBC?
A URL string
-->getConnection-->DriverManager-->Driver-->Connection-->Statement-->executeQuery-->ResultSet.

What are the steps involved in establishing a connection?
This involves two steps: (1) loading the driver and (2) making the connection.

How can you load the drivers?
Loading the driver or drivers you want to use is very simple and involves just one line of code. If, for example, you want to use the JDBC-ODBC Bridge driver, the following code will load it:

Eg.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Your driver documentation will give you the class name to use. For instance, if the class name is jdbc.DriverXYZ , you would load the driver with the following line of code:

E.g.
Class.forName("jdbc.DriverXYZ");

What Class.forName will do while loading drivers?
It is used to create an instance of a driver and register it with the DriverManager. When you have loaded a driver, it is available for making a connection with a DBMS.

How can you make the connection?
In establishing a connection is to have the appropriate driver connect to the DBMS. The following line of code illustrates the general idea:

E.g.
String url = "jdbc:odbc:red";
Connection con = DriverManager.getConnection(url, "Admin", "tiger");

How can you create JDBC statements?
A Statement object is what sends your SQL statement to the DBMS. You simply create a Statement object and then execute it, supplying the appropriate execute method with the SQL statement you want to send. For a SELECT statement, the method to use is executeQuery. For statements that create or modify tables, the method to use is executeUpdate. E.g. It takes an instance of an active connection to create a Statement object. In the following example, we use our Connection object con to create the Statement object stmt : Statement stmt = con.createStatement();

How can you retrieve data from the ResultSet?
First JDBC returns results in a ResultSet object, so we need to declare an instance of the class ResultSet to hold our results. The following code demonstrates declaring the ResultSet object rs.
E.g.
ResultSet rs = stmt.executeQuery("SELECT NAME, SAL FROM Employee");
Second:String s = rs.getString("NAME");

The method getString is invoked on the ResultSet object rs , so getString will retrieve (get) the value stored in the column NAME in the current row of rs

What are the different types of Statements?
1.Statement (use createStatement method) 2. Prepared Statement (Use prepareStatement method) and 3. Callable Statement (Use prepareCall)

How can you use PreparedStatement?
This special type of statement is derived from the more general class, Statement. If you want to execute a Statement object many times, it will normally reduce execution time to use a PreparedStatement object instead. The advantage to this is that in most cases, this SQL statement will be sent to the DBMS right away, where it will be compiled. As a result, the PreparedStatement object contains not just an SQL statement, but an SQL statement that
has been precompiled. This means that when the PreparedStatement is executed, the DBMS can just run the PreparedStatement 's SQL statement without having to compile it first.

E.g.
PreparedStatement updateSales = con.prepareStatement("UPDATE Employee SET SAL= ? WHERE DEST LIKE ?");

How to call a Stored Procedure from JDBC?
The first step is to create a CallableStatement object. As with Statement an and PreparedStatement objects, this is done with an open Connection object. A
CallableStatement object contains a call to a stored procedure;

E.g.
CallableStatement cs = con.prepareCall("{call SHOW_EMPLOYEES}");
ResultSet rs = cs.executeQuery();
How to Retrieve Warnings?
SQLWarning objects are a subclass of SQLException that deal with database access warnings.
Warnings do not stop the execution of an application, as exceptions do; they simply alert the user that something did not happen as planned. A warning can be reported on a Connection object, a Statement object (including PreparedStatement and CallableStatement objects), or a ResultSet object. Each of these classes has a getWarnings method, which you must invoke in order to see the first warning reported on the calling object

E.g.
SQLWarning warning = stmt.getWarnings();

if (warning != null) {

while (warning != null) {

System.out.println("Message: " + warning.getMessage());

System.out.println("SQLState: " + warning.getSQLState());

System.out.print("Vendor error code: ");

System.out.println(warning.getErrorCode());

warning = warning.getNextWarning();

}

}

How to Make Updates to Updatable Result Sets?
Another new feature in the JDBC 2.0 API is the ability to update rows in a result set using methods in the Java programming language rather than having to send an SQL command. But before you can take advantage of this capability, you need to create a ResultSet
object that is updatable. In order to do this, you supply the ResultSet constant
CONCUR_UPDATABLE to the createStatement method.
E.g.Connection con = DriverManager.getConnection("jdbc:mySubprotocol:mySubName");
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,

ResultSet.CONCUR_UPDATABLE);

ResultSet uprs = ("SELECT NAME, SAL FROM Employee");

Servlets Interview Questions & Answers

Servlets Interview Questions & Answers

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 is the architechture of servlet package?
Servlet Interface is the central abstraction. All servlets implements this Servlet
Interface either direclty or indirectly
( may implement or extend Servlet Interfaces sub classes or sub interfaces)


Servlet
|
Generic Servlet
|
HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests
|
MyServlet


What is the difference between HttpServlet and GenericServlet?
A GenericServlet has a service() method to handle requests.
HttpServlet extends GenericServlet added new methods
doGet()
doPost()
doHead()
doPut()
doOptions()
doDelete()
doTrace() methods
Both these classes are abstract.

What's the difference between servlets and applets?
Servlets executes on Servers. Applets executes on browser. Unlike applets, however, servlets have no graphical user interface.

What are the uses of Servlets?
A servlet can handle multiple requests concurrently, and can synchronize requests. Servlets can forward requests to other servers and servlets. Thus servlets can be used to balance load among several servers.

When doGET() method will going to execute?
When we specified method='GET' in HTML
Example : < form name='SSS' method='GET'>

When doPOST() method will going to execute?
When we specified method='POST' in HTML
< form name='SSS' method='POST' >


What is the difference between Difference between doGet() and doPost()?
GET Method : Using get method we can able to pass 2K data from HTML
All data we are passing to Server will be displayed in URL (request string).

POST Method : In this method we does not have any size limitation.
All data passed to server will be hidden, User cannot able to see this info
on the browser.

What is the servlet life cycle?
When first request came in for the servlet , Server will invoke init() method of the servlet. There after if any user request the servlet program, Server will directly executes the service() method. When Server want to remove the servlet from pool, then it will execute the destroy() method

Which code line must be set before any of the lines that use the PrintWriter?
setContentType() method must be set.

Which protocol will be used by browser and servlet to communicate ?
HTTP


In how many ways we can track the sessions?
Method 1) By URL rewriting

Method 2) Using Session object

Getting Session form HttpServletRequest object
HttpSession session = request.getSession(true);

Get a Value from the session
session.getValue(session.getId());

Adding values to session
cart = new Cart();
session.putValue(session.getId(), cart);

At the end of the session, we can inactivate the session by using the following command
session.invalidate();

Method 3) Using cookies

Method 4) Using hidden fields



How Can You invoke other web resources (or other servelt / jsp ) ?
Servelt can invoke other Web resources in two ways: indirect and direct.

Indirect Way : Servlet will return the resultant HTML to the browser which will point to another Servlet (Web resource)

Direct Way : We can call another Web resource (Servelt / Jsp) from Servelt program itself, by using RequestDispatcher object.

You can get this object using getRequestDispatcher("URL") method. You can get this object from either a request or a Context.

Example :
RequestDispatcher dispatcher = request.getRequestDispatcher("/jspsample.jsp");
if (dispatcher != null)
dispatcher.forward(request, response);
}

How Can you include other Resources in the Response?
Using include method of a RequestDispatcher object.

Included WebComponent (Servlet / Jsp) cannot set headers or call any method (for example, setCookie) that affects the headers of the response.

Example : RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/banner");
if (dispatcher != null)
dispatcher.include(request, response);
}

What is the difference between the getRequestDispatcher(String path) ServletRequest interface and ServletContext interface?
The getRequestDispatcher(String path) method of ServletRequest interface accepts parameter the path to the resource to be included or forwarded to, which can be relative to the request of the calling servlet. If the path begins with a "/" it is interpreted as relative to the current context root.

The getRequestDispatcher(String path) method of ServletContext interface cannot accepts relative paths. All path must sart with a "/" and are interpreted as relative to curent context root. If the resource is not available, or if the server has not implemented a RequestDispatcher object for that type of resource, getRequestDispatcher will return null. Your servlet should be prepared to deal with this condition.

What is the use of ServletContext ?
Using ServletContext, We can access data from its environment. Servlet context is common to all Servlets so all Servlets share the information through ServeltContext.

Is there any way to generate PDF'S dynamically in servlets?
We need to use iText. A open source library for java. Please refer sourceforge site for sample servlet examples.

What is the difference between using getSession(true) and getSession(false) methods?
getSession(true) - This method will check whether already a session is existing for the user. If a session is existing, it will return that session object, Otherwise it will create new session object and return taht object.

getSession(false) - This method will check existence of session. If session exists, then it returns the reference of that session object, if not, this methods will return null.
sri

Posts: 686
Joined: Fri Jun 27, 2008 12:33 pm
Top
________________________________________
Struts Interview Questions & Answers
by sri on Mon Jul 28, 2008 3:49 pm
Q: What is Jakarta Struts Framework?
A: 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.

Q: What is ActionServlet?
A: 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 controller. Controller is responsible for handling all the requests.


Q: How you will make available any Message Resources Definitions file to the Struts Framework Environment?
A: 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 tag.
Example:



Q: What is Action Class?
A: 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 the action. The action should receive the request, call business objects (which then handle database, or interface with J2EE, etc) and then determine where to go next. Even better, the business objects could be handed to the action at runtime (IoC style) thus removing any dependencies on the model. The return type of the execute method is ActionForward which is used by the Struts Framework to forward the request to the file as per the value of the returned ActionForward object.


Q: Write code of any Action Class?
A: Here is the code of Action Class that returns the ActionForward object.
TestAction.java package roseindia.net;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class TestAction extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
return mapping.findForward("testAction");
}
}

Q: What is ActionForm?
A: An ActionForm is a JavaBean that extends org.apache.struts.action.ActionForm. ActionForm maintains the session state for web application and the ActionForm object is automatically populated on the server side with data entered from a form on the client side.


Q: What is Struts Validator Framework?
A: 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 accomplished by sub classing your From Bean with DynaValidatorForm class.

The Validator framework was developed by David Winterfeldt as third-party add-on to Struts. Now the Validator framework is a part of Jakarta Commons project and it can be used with or without Struts. The Validator framework comes integrated with the Struts Framework and can be used without doing any extra settings.


Q. Give the Details of XML files used in Validator Framework?
A: The Validator Framework uses two XML configuration files validator-rules.xml and validation.xml. The validator-rules.xml defines the standard validation routines, these are reusable and used in validation.xml. to define the form specific validations. The validation.xml defines the validations applied to a form bean.

Q. How you will display validation fail errors on jsp page?
A: Following tag displays all the errors:



Q. How you will enable front-end validation based on the xml in validation.xml?
A: The tag to allow front-end validation based on the xml in validation.xml. For example the code: generates the client side java script for the form "logonForm" as defined in the validation.xml file. The when added in the jsp file generates the client site validation script.

Question: What is RequestProcessor and RequestDispatcher?
Answer: The controller is responsible for intercepting and translating user input into actions to be performed by the model. The controller is responsible for selecting the next view based on user input and the outcome of model operations. The Controller receives the request from the browser, invoke a business operation and coordinating the view to return to the client.

The controller is implemented by a java servlet, this servlet is centralized point of control for the web application. In struts framework the controller responsibilities are implemented by several different components like
The ActionServlet Class
The RequestProcessor Class
The Action Class

The ActionServlet extends the javax.servlet.http.httpServlet class. The ActionServlet class is not abstract and therefore can be used as a concrete controller by your application.
The controller is implemented by the ActionServlet class. All incoming requests are mapped to the central controller in the deployment descriptor as follows.

action
org.apache.struts.action.ActionServlet



All request URIs with the pattern *.do are mapped to this servlet in the deployment descriptor as follows.


action
*.do
*.do
A request URI that matches this pattern will have the following form.
http://www.my_site_name.com/mycontext/actionName.do

The preceding mapping is called extension mapping, however, you can also specify path mapping where a pattern ends with /* as shown below.

action
/do/*
*.do
A request URI that matches this pattern will have the following form.
http://www.my_site_name.com/mycontext/do/action_Name
The class org.apache.struts.action.requestProcessor process the request from the controller. You can sublass the RequestProcessor with your own version and modify how the request is processed.

Once the controller receives a client request, it delegates the handling of the request to a helper class. This helper knows how to execute the business operation associated with the requested action. In the Struts framework this helper class is descended of org.apache.struts.action.Action class. It acts as a bridge between a client-side user action and business operation. The Action class decouples the client request from the business model. This decoupling allows for more than one-to-one mapping between the user request and an action. The Action class also can perform other functions such as authorization, logging before invoking business operation. the Struts Action class contains several methods, but most important method is the execute() method.
public ActionForward execute(ActionMapping mapping,
ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception;
The execute() method is called by the controller when a request is received from a client. The controller creates an instance of the Action class if one doesn’t already exist. The strut framework will create only a single instance of each Action class in your application.

Action are mapped in the struts configuration file and this configuration is loaded into memory at startup and made available to the framework at runtime. Each Action element is represented in memory by an instance of the org.apache.struts.action.ActionMapping class . The ActionMapping object contains a path attribute that is matched against a portion of the URI of the incoming request.

path= "/somerequest"
type="com.somepackage.someAction"
scope="request"
name="someForm"
validate="true"
input="somejsp.jsp"



Once this is done the controller should determine which view to return to the client. The execute method signature in Action class has a return type org.apache.struts.action.ActionForward class. The ActionForward class represents a destination to which the controller may send control once an action has completed. Instead of specifying an actual JSP page in the code, you can declaratively associate as action forward through out the application. The action forward are specified in the configuration file.

path= "/somerequest"
type="com.somepackage.someAction"
scope="request"
name="someForm"
validate="true"
input="somejsp.jsp"



The action forward mappings also can be specified in a global section, independent of any specific action mapping.





public interface RequestDispatcher

Defines an object that receives requests from the client and sends them to any resource (such as a servlet, HTML file, or JSP file) on the server. The servlet container creates the RequestDispatcher object, which is used as a wrapper around a server resource located at a particular path or given by a particular name.
This interface is intended to wrap servlets, but a servlet container can create RequestDispatcher objects to wrap any type of resource.

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(java.lang.String path)

Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response. The resource can be dynamic or static.
The pathname must begin with a "/" and is interpreted as relative to the current context root. Use getContext to obtain a RequestDispatcher for resources in foreign contexts. This method returns null if the ServletContext cannot return a RequestDispatcher.

Parameters:
path - a String specifying the pathname to the resource
Returns:
a RequestDispatcher object that acts as a wrapper for the resource at the specified path
See Also:
RequestDispatcher, getContext(java.lang.String)

getNamedDispatcher

public RequestDispatcher getNamedDispatcher(java.lang.String name)

Returns a RequestDispatcher object that acts as a wrapper for the named servlet.
Servlets (and JSP pages also) may be given names via server administration or via a web application deployment descriptor. A servlet instance can determine its name using ServletConfig.getServletName().
This method returns null if the ServletContext cannot return a RequestDispatcher for any reason.

Parameters:
name - a String specifying the name of a servlet to wrap
Returns:
a RequestDispatcher object that acts as a wrapper for the named servlet
See Also:
RequestDispatcher, getContext(java.lang.String), ServletConfig.getServletName()



Question: Why cant we overide create method in StatelessSessionBean?
Answer: From the EJB Spec : - A Session bean's home interface defines one or morecreate(...) methods. Each create method must be named create and must match one of the ejbCreate methods defined in the enterprise Bean class. The return type of a create method must be the enterprise Bean's remote interface type. The home interface of a stateless session bean must have one create method that takes no arguments.


Question: Is struts threadsafe?Give an example?
Answer: Struts is not only thread-safe but thread-dependant. The response to a request is handled by a light-weight Action object, rather than an individual servlet. Struts instantiates each Action class once, and allows other requests to be threaded through the original object. This core strategy conserves resources and provides the best possible throughput. A properly-designed application will exploit this further by routing related operations through a single Action.


Question: Can we Serialize static variable?
Answer: Serialization is the process of converting a set of object instances that contain references to each other into a linear stream of bytes, which can then be sent through a socket, stored to a file, or simply manipulated as a stream of data. Serialization is the mechanism used by RMI to pass objects between JVMs, either as arguments in a method invocation from a client to a server or as return values from a method invocation. In the first section of this book, There are three exceptions in which serialization doesnot necessarily read and write to the stream. These are
1. Serialization ignores static fields, because they are not part of any particular object's state.
2. Base class fields are only handled if the base class itself is serializable.
3. Transient fields. There are four basic things you must do when you are making a class serializable. They are:

Implement the Serializable interface.
Make sure that instance-level, locally defined state is serialized properly.
Make sure that superclass state is serialized properly.
Override equals( )and hashCode( ).
it is possible to have control over serialization process. The class should implement Externalizable interface. This interface contains two methods namely readExternal and writeExternal. You should implement these methods and write the logic for customizing the serialization process .... (Source: http://www.oreilly.com/catalog/javarmi/ ... /ch10.html)

Question: What are the uses of tiles-def.xml file, resourcebundle.properties file, validation.xml file?
Answer: tiles-def.xml is is an xml file used to configure tiles with the struts application. You can define the layout / header / footer / body content for your View. See more at http://www.roseindia.net/struts/using-t ... -xml.shtml.

The resourcebundle.properties file is used to configure the message (error/ other messages) for the struts applications.

The file validation.xml is used to declare sets of validations that should be applied to Form Beans. Fpr more information please visit http://www.roseindia.net/struts/address ... ator.shtml.

Question: What is the difference between perform() and execute() methods?
Answer: 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 exception handling, the method signature changed in perform. Now execute just throws Exception. Action.perform() is now deprecated; however, the Struts v1.1 ActionServlet is smart enough to know whether or not it should call perform or execute in the Action, depending on which one is available.


Question: What are the various Struts tag libraries?
Answer: 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, including forms, text boxes, checkboxes, radio buttons etc..
* Logic tag library - Tags for generating conditional output, iteration capabilities and flow management
* Tiles or Template tag library - For the application using tiles
* Nested tag library - For using the nested beans in the application


Question: What do you understand by DispatchAction?
Answer: DispatchAction is an action that comes with Struts 1.1 or later, that lets you combine Struts actions into one class, each with their own method. The org.apache.struts.action.DispatchAction class allows multiple operation to mapped to the different functions in the same Action class.
For example:
A package might include separate RegCreate, RegSave, and RegDelete Actions, which just perform different operations on the same RegBean object. Since all of these operations are usually handled by the same JSP page, it would be handy to also have them handled by the same Struts Action.

A very simple way to do this is to have the submit button modify a field in the form which indicates which operation to perform.



SAVE
SAVE AS NEW
DELETE

Then, in the Action you can setup different methods to handle the different operations, and branch to one or the other depending on which value is passed in the dispatch field.

String dispatch = myForm.getDispatch();
if ("create".equals(dispatch)) { ...
if ("save".equals(dispatch)) { ...

The Struts Dispatch Action [org.apache.struts.actions] is designed to do exactly the same thing, but without messy branching logic. The base perform method will check a dispatch field for you, and invoke the indicated method. The only catch is that the dispatch methods must use the same signature as perform. This is a very modest requirement, since in practice you usually end up doing that anyway.

To convert an Action that was switching on a dispatch field to a DispatchAction, you simply need to create methods like this

public ActionForward create(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException { ...

public ActionForward save(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException { ...

Cool. But do you have to use a property named dispatch? No, you don't. The only other step is to specify the name of of the dispatch property as the "parameter" property of the action-mapping. So a mapping for our example might look like this:

path="/reg/dispatch"
type="app.reg.RegDispatch"
name="regForm"
scope="request"
validate="true"
parameter="dispatch"/>

If you wanted to use the property "o" instead, as in o=create, you would change the mapping to

path="/reg/dispatch"
type="app.reg.RegDispatch"
name="regForm"
scope="request"
validate="true"
parameter="o"/>

Again, very cool. But why use a JavaScript button in the first place? Why not use several buttons named "dispatch" and use a different value for each?

You can, but the value of the button is also its label. This means if the page designers want to label the button something different, they have to coordinate the Action programmer. Localization becomes virtually impossible. (Source: http://husted.com/struts/tips/002.html).


Question: How Struts relates to J2EE?
Answer: Struts framework is built on J2EE technologies (JSP, Servlet, Taglibs), but it is itself not part of the J2EE standard.


Question: What is Struts actions and action mappings?
Answer: 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 an action name with an action. An action mapping can contain a reference to a form bean that the action can use, and can additionally define a list of local forwards that is visible only to this action.

An action servlet is a servlet that is started by the servlet container of a Web server to process a request that invokes an action. The servlet receives a forward from the action and asks the servlet container to pass the request to the forward's URL. An action servlet must be an instance of an org.apache.struts.action.ActionServlet class or of a subclass of that class. An action servlet is the primary component of the controller.

Question: Can I setup Apache Struts to use multiple configuration files?
Answer: Yes Struts can use multiple configuration files. Here is the configuration example:

banking
org.apache.struts.action.ActionServlet


config
/WEB-INF/struts-config.xml,
/WEB-INF/struts-authentication.xml,
/WEB-INF/struts-help.xml


1



Question: What are the disadvantages of Struts?
Answer: Struts is very robust framework and is being used extensively in the industry. But there are some disadvantages of the Struts:
a) High Learning Curve
Struts requires lot of efforts to learn and master it. For any small project less experience developers could spend more time on learning the Struts.

b) Harder to learn
Struts are harder to learn, benchmark and optimize.

Question: What is Struts Flow?
Answer: 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 is based on a proof-of-concept Dave Johnson put together to show how the Control Flow could be extracted from Cocoon. (Ref: http://struts.sourceforge.net/struts-flow/index.html )

Question: What are the difference between and ?
Answer: : This tag is used to output locale-specific text (from the properties files) from a MessageResources bundle.

: This tag is used to output property values from a bean. is a commonly used tag which enables the programmers to easily present the data.

Question: What is LookupDispatchAction?
Answer: 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/ ... ction.html).

Question: What are the components of Struts?
Answer: 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 controller to handle all the requests.

Question: What are Tag Libraries provided with Struts?
Answer: Struts provides a number of tag libraries that helps to create view components easily. These tag libraries are:
a) Bean Tags: Bean Tags are used to access the beans and their properties.
b) HTML Tags: HTML Tags provides tags for creating the view components like forms, buttons, etc..
c) Logic Tags: Logic Tags provides presentation logics that eliminate the need for scriptlets.
d) Nested Tags: Nested Tags helps to work with the nested context.

Question: What are the core classes of the Struts Framework?
Answer: Core classes of Struts Framework are ActionForm, Action, ActionMapping, ActionForward, ActionServlet etc.

Question: What are difference between ActionErrors and ActionMessage?
Answer: 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 resulting message.

ActionErrors: A class that encapsulates the error messages being reported by the validate() method of an ActionForm. Validation errors are either global to the entire ActionForm bean they are associated with, or they are specific to a particular bean property (and, therefore, a particular input field on the corresponding form).

Question: How you will handle exceptions in Struts?
Answer: 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 .. tag.
Example:

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.
http://www.roseindia.net
sri

Posts: 686
Joined: Fri Jun 27, 2008 12:33 pm
Top
________________________________________

ஜ்ச்ப் details

1. What is JSF (or JavaServer Faces)?
A server side user interface component framework for Java™ technology-based web applications.JavaServer Faces (JSF) is an industry standard and a framework for building component-based user interfaces for web applications.

JSF contains an API for representing UI components and managing their state; handling events, server-side validation, and data conversion; defining page navigation; supporting internationalization and accessibility; and providing extensibility for all these features.
New to JSF ? Check JavaServer Faces (JSF) tutorial
2. What are the advantages of JSF?
The major benefits of JavaServer Faces technology are:
• JavaServer Faces architecture makes it easy for the developers to use. In JavaServer Faces technology, user interfaces can be created easily with its built-in UI component library, which handles most of the complexities of user interface management.
• Offers a clean separation between behavior and presentation.
• Provides a rich architecture for managing component state, processing component data, validating user input, and handling events.
• Robust event handling mechanism.
• Events easily tied to server-side code.
• Render kit support for different clients
• Component-level control over statefulness
• Highly 'pluggable' - components, view handler, etc
• JSF also supports internationalization and accessibility
• Offers multiple, standardized vendor implementations
3. What are differences between struts and JSF?
In a nutshell, Faces has the following advantages over Struts:
• Eliminated the need for a Form Bean
• Eliminated the need for a DTO Class
• Allows the use of the same POJO on all Tiers because of the Backing Bean

The primary advantages of Struts as compared to JavaServer Faces technology are as follows:
• Because Struts is a web application framework, it has a more sophisticated controller architecture than does JavaServer Faces technology. It is more sophisticated partly because the application developer can access the controller by creating an Action object that can integrate with the controller, whereas JavaServer Faces technology does not allow access to the controller. In addition, the Struts controller can do things like access control on each Action based on user roles. This functionality is not provided by JavaServer Faces technology.

• Struts includes a powerful layout management framework, called Tiles, which allows you to create templates that you can reuse across multiple pages, thus enabling you to establish an overall look-and-feel for an application.
• The Struts validation framework includes a larger set of standard validators, which automatically generate both server-side and client-side validation code based on a set of rules in a configuration file. You can also create custom validators and easily include them in your application by adding definitions of them in your configuration file.

The greatest advantage that JavaServer Faces technology has over Struts is its flexible, extensible UI component model, which includes:
• A standard component API for specifying the state and behavior of a wide range of components, including simple components, such as input fields, and more complex components, such as scrollable data tables. Developers can also create their own components based on these APIs, and many third parties have already done so and have made their component libraries publicly available.
• A separate rendering model that defines how to render the components in various ways. For example, a component used for selecting an item from a list can be rendered as a menu or a set of radio buttons.
• An event and listener model that defines how to handle events generated by activating a component, such as what to do when a user clicks a button.
• Conversion and validation models for converting and validating component data.
4. What are the available implementations of JavaServer Faces?
The main implementations of JavaServer Faces are:
• Reference Implementation (RI) by Sun Microsystems.
• Apache MyFaces is an open source JavaServer Faces (JSF) implementation or run-time.
• ADF Faces is Oracle’s implementation for the JSF standard.

6. What typical JSF application consists of?
A typical JSF application consists of the following parts:
• JavaBeans components for managing application state and behavior.
• Event-driven development (via listeners as in traditional GUI development).
• Pages that represent MVC-style views; pages reference view roots via the JSF component tree.

7. What Is a JavaServer Faces Application?
JavaServer Faces applications are just like any other Java web application. They run in a servlet container, and they typically contain the following:
• JavaBeans components containing application-specific functionality and data.
• Event listeners.
• Pages, such as JSP pages.
• Server-side helper classes, such as database access beans.
In addition to these items, a JavaServer Faces application also has:
• A custom tag library for rendering UI components on a page.
• A custom tag library for representing event handlers, validators, and other actions.
• UI components represented as stateful objects on the server.
• Backing beans, which define properties and functions for UI components.
• Validators, converters, event listeners, and event handlers.
• An application configuration resource file for configuring application resources.

8. What is Managed Bean?
People who read this, also read:-
• EJB Interview Questions
• Hibernate Questions
• Spring Tutorial
• AJAX Form Validation Using DWR and Spring
• Spring Interview Questions

JavaBean objects managed by a JSF implementation are called managed beans. A managed bean describes how a bean is created and managed. It has nothing to do with the bean's functionalities.

9. What is Backing Bean?
Backing beans are JavaBeans components associated with UI components used in a page. Backing-bean management separates the definition of UI component objects from objects that perform application-specific processing and hold data.
The backing bean defines properties and handling-logics associated with the UI components used on the page. Each backing-bean property is bound to either a component instance or its value. A backing bean also defines a set of methods that perform functions for the component, such as validating the component's data, handling events that the component fires and performing processing associated with navigation when the component activates.

10. What are the differences between a Backing Bean and Managed Bean?
Backing Beans are merely a convention, a subtype of JSF Managed Beans which have a very particular purpose. There is nothing special in a Backing Bean that makes it different from any other managed bean apart from its usage.

What makes a Backing Bean is the relationship it has with a JSF page; it acts as a place to put component references and Event code.

Backing Beans Managed Beans
A backing bean is any bean that is referenced by a form. A managed bean is a backing bean that has been registered with JSF (in faces-config.xml) and it automatically created (and optionally initialized) by JSF when it is needed.
The advantage of managed beans is that the JSF framework will automatically create these beans, optionally initialize them with parameters you specify in faces-config.xml,
Backing Beans should be defined only in the request scope The managed beans that are created by JSF can be stored within the request, session, or application scopes

Backing Beans should be defined in the request scope, exist in a one-to-one relationship with a particular page and hold all of the page specific event handling code.In a real-world scenario, several pages may need to share the same backing bean behind the scenes.A backing bean not only contains view data, but also behavior related to that data.
11. What is view object?
A view object is a model object used specifically in the presentation tier. It contains the data that must display in the view layer and the logic to validate user input, handle events, and interact with the business-logic tier. The backing bean is the view object in a JSF-based application. Backing bean and view object are interchangeable terms.

eclipse Keyboard Shortcut

Keyboard Shortcut Task
Ctrl + Space Content Assist (also Templates invoking)
Ctrl + Shift + Space Context Information/Show Parameter
Ctrl + C Copy the selection to the clipboard
Change the encoding to a custom encoding
Ctrl + X Cut the selection to the clipboard
Delete the selection
Ctrl + F Find and Replace
Ctrl + K Find next
Ctrl + Shift + K Find previous
Ctrl + J Incremental Find
Ctrl + Shift + J Incremental Find reverse
Change the encoding to ISO-8859-1
Ctrl + V Paste from the clipboard
Ctrl + 1 Quick Fix
Ctrl + Y Redo the last operation
Alt + Shift + ↓ Restore Last Selection
Revert to the state after the most recent save operation
Ctrl + A Select All
Alt + Shift + ↑ Expand selection to include enclosing element
Alt + Shift + → Expand selection to include next sibling
Alt + Shift + ← Expand selection to include previous sibling
Shift a block of text to the left
Shift a block of text to the right
F2 Show tooltip/javadoc description for the element at the cursor
Change the encoding to the system encoding
Ctrl + Z Undo the last operation
Change the encoding to US ASCII
Change the encoding to UTF-16BE
Change the encoding to UTF-16
Change the encoding to UTF-16LE
Change the encoding to UTF-8
Navigation Shortcuts

Keyboard Shortcut Task
Alt + ← Navigate back
Move backward in the editor navigation history
Alt + → Navigate forward
Move forward in the editor navigation history
Navigate into the selected item
Ctrl + Q Go to last edit location
Ctrl + L Go to Line
Ctrl + Shift + P Moves the cursor to the matching bracket
Ctrl + Shift + ↓ Go to Next Member
Go to next problem
Ctrl + Shift + ↑ Go to Previous Member
Go to Previous Problem
Go to Resource in the active view
Ctrl + . Navigate to the next item
Ctrl + Alt + H Open Call Hierarchy
F3 Open Declaration (Open an editor on the selected element)
Shift + F2 Open External Javadoc
Alt + F3 Opens an implementation of a method call on an interface
Ctrl + Alt + F3 Opens an interface declaration of a method call
Opens an editor on a particular resource
Ctrl + F3 Show the structure of the selected element
Open the Implementation in the Super Type
Ctrl + Shift + T Open a type in a Java editor
F4 Open a type hierarchy on the selected element
Ctrl + Shift + H Open a type in the type hierarchy view
Ctrl + , Navigate to the previous item
Show in Package Explorer
Ctrl + O Show Outline
Up (Navigate up one level)
File Shortcuts

Keyboard Shortcut Task
Ctrl + F4 Close the active editor
Ctrl + Shift + F4 Close all editors
Move the selected item
Ctrl + N Open the New item wizard
Ctrl + P Print
Alt + Enter Display the properties of the selected item
Refresh the selected item
Rename the selected item
Revert to the last saved state
Ctrl + S Save the current contents
Ctrl + Shift + S Save all current contents
Refactoring Shortcuts

Keyboard Shortcut Task
Alt + Shift + L Change Method Signature
Convert Anonymous Class to Nested
Convert Local Variable to Field
Convert Nested Type to Top Level
Encapsulate Field (Create getting and setting
methods)
Extracts a constant into a new static field
Extract a set of members into a new interface
Extracts an expression into a new local variable
Alt + Shift + M Extracts a set of statements or an expression into a new method
Alt + Shit + I Inline a constant, local variable or method
Alt + Shift + V Move – Refactoring
Pull Up (Move members to a superclass)
Push Down (Move members to subclasses)
Alt + Shit + Y Redo – Refactoring
Alt + Shift + R Rename – Refactoring
Alt + Shift + Z Undo – Refactoring
Use Supertype Where Possible (Re-route)
Run/Debug Shortcuts

Keyboard Shortcut Task
Ctrl + Shift + B Add/Remove Breakpoint
Add/Remove Method Breakpoint
Add/Remove Watchpoint
Add Java Exception Breakpoint
F11 Debug...
Debug Last Launched
Ctrl + D Display result of evaluating selected text
Ctrl + U Execute: evaluate selected text
Inspect result of evaluating selected text
F8 Resume
Run …
Ctrl + F11 Run Last Launched
Run Last Launched External Tool
Ctrl + R Run to Line
F5 Step Into
Ctrl + F5 Step Into Selection
F6 Step over
F7 Step Return
Shift + F5 Step with filters
Suspend
Terminate
Search Shortcuts

Keyboard Shortcut Task
Ctrl + G Declaration in Hierarchy
Declaration in Working Set
Declaration in Workspace
Ctrl + Shift + U File Search
Implementors in Working Set
Implementors in Workspace
Occurrences in File
Ctrl + H Open Search Dialog
Ctrl + Shift + G Read Access in Hierarchy
Read Access in Working Set
Read Access in Workspace
References in Hierarchy
References in Working Set
References in Workspace
Write Access in Hierarchy
Write Access in Working Set
Write Access in Workspace

collection

A collections framework is a unified architecture for representing and manipulating collections. All collections frameworks contain the following:
  • Interfaces: These are abstract data types that represent collections. Interfaces allow collections to be manipulated independently of the details of their representation. In object-oriented languages, interfaces generally form a hierarchy.
  • Implementations: These are the concrete implementations of the collection interfaces. In essence, they are reusable data structures.
  • Algorithms: These are the methods that perform useful computations, such as searching and sorting, on objects that implement collection interfaces. The algorithms are said to be polymorphic: that is, the same method can be used on many different implementations of the appropriate collection interface. In essence, algorithms are reusable functionality.

Apart from the Java Collections Framework, the best-known examples of collections frameworks are the C++ Standard Template Library (STL) and Smalltalk's collection hierarchy. Historically, collections frameworks have been quite complex, which gave them a reputation for having a steep learning curve. We believe that the Java Collections Framework breaks with this tradition, as you will learn for yourself in this chapter.