Java EE Knowledge System __java

Source: Internet
Author: User
Tags java web

This article records the majority of my knowledge of Java EE during my college years, and as a simple primer for people who haven't touched Java EE, the content of this blog is, after all, just the tip of the iceberg.

Chapter 1
A. What is a Java EE component.
Java EE application is composed of components, the Java EE component is a stand-alone functional software unit (such as a stand-alone function of the Jsp,javabean,servlet and other class files are a component), it and other related categories and files are assembled into a Java EE application ( Other files include such as picture resources, FLASH, CSS format control, etc., and communicate with other components (such as using the requested dispatch forward, redirects, session,cookies, etc.). Java EE components are written in the JavaScript, and the Java EE component differs from the standard Java class in that it needs to be assembled into a EE application, validated to be well-formed and followed by Java EE specifications, and deployed to the production environment. Run and manage through a Java EE server.

two. List all containers in the Java EE Server and give a definition of all containers.
Java EE provides a total of four kinds of containers:
Apply client containers, small application containers, web containers, Enterprise Javavbeans (EJB) containers.
① applies client containers: manages the execution of application client components, application clients, and their containers run on the client.
② Small Application container: Manages the execution of small applications, made up of web browsers and Java Plug-ins that run together on the client.
③web container: Manages JSP pages and servlet component execution for Java EE applications, and Web components and their containers run on Java EE servers.
④ Enterprise JavaBeans (EJB) Container: Manages the execution of enterprise beans for Java EE applications, and enterprise beans and their containers run on Java EE servers.

three. Describe all the Java EE components?
The Java EE components include:
(1) A component that runs on the client: it can be a Web browser, an applet, or it can be an ordinary client Java application.
(2) Web technology components running on the server, mainly including Java Servlet and JSP,JSF.
(3) The EJB business component running on the server: Session bean (conversation bean), Entity bean (Entity Bean), and message-driven bean (message-driven bean).

Four. What is a Java EE module.
The Java EE module is made up of one or more JavaScript components for the same container type and a component deployment descriptor that belongs to that type. For example, the Enterprise Bean Module deployment descriptor declares transaction attributes and security authorization for enterprise beans.

five. List all Java EE modules and give a description of them.
The Java EE module is as follows: (each module has an. XML configuration Descriptor)
(1). EJB module:
class files containing enterprise beans (for processing logical business, normal Java classes), and an EJB configuration description file, the EJB module is packaged as a jar file with the. jar extension.
(2). Web module:
Contains servlet class files, JSP files, support class files (such as CSS format control), graphics files (gif or JPG images), HTML files, and a Web application deployment profile. The Web module is packaged as a war (Web Archive file,web application file) with the extension. War.
(3). Application Client module: Contains the class file and an application client configuration description file. The application client module is packaged into a jar file with a. jar extension.
(4). Resource Adapter module: Contains all Java interfaces, classes, local libraries and other documents, and resource adapter configuration profiles. Together, they implement a connector architecture for a particular EIS. The resource adapter module is packaged into a jar file with a. jar extension.

Six. Please draw the ear file structure of the Java EE application (Structure of Enterprise Archive file).

Chapter 2
A. What are servlet and JSP?
(1) A servlet component is a functional module that implements an HTTP request and generates an HTTP request response, which is actually a Java class file.
(2) A JSP component is a text document that contains static elements (Html,xml, etc.) and JSP elements. When the server runs the JSP component, it is translated into a servlet for execution.

two. Details the steps that the Web client interacts with the Web application.
(1) The client sends an HTTP request to the Web server;
(2) The Web server that implements the Javaservlet and JSP page technology transforms the request to the HttpServletRequest object;
(3) The server passes the object to a Web component that can be used with the database or JavaBeans
The component interacts to claim dynamic content, or to pass the request object to another Web component;
(4) The Web Component generates a HttpServletResponse object, which is returned to the client by the Web server to convert the object to an HTTP response.

three. What is a Web component?
The Web component can be either a Java Servlet, a JSP page, or a Web service endpoint.

four. Describe the life cycle of Web applications?
The process of creating, deploying, and executing Web applications is summarized as follows:
(1) Development of Web Component code
(2) Development of Web application deployment descriptors
(3) Compiling the helper classes referenced by the Web application components and components
(4) Optionally package the application to a deployable unit
(5) Deploy the application to a Web container
(6) Accessing URLs that refer to Web applications

Five. Gives the definition of the document root and the upper and lower root (documents root and context root). and describe their differences.
(1) The definition of the document root: The top-level directory of the Web module is the document root of the application, and the document root is where the JSP pages, client classes and files, and static Web resources are saved.
(2) definition of upper and lower root: The context root identifies a Web application in the Java EE server. The user needs to specify the context root when deploying the Web module. The context root must begin with a forward slash (/) and end with a string.
(3) Distinction: Document root is used to identify document resources, it can facilitate users to manage files. And up and down root is to identify a Web application, it can tell the server to find the application. One is to manage the documents in the hard disk, a management network of applications.

Six. Draw the Web module structure diagram.

Chapter 3
A. What is a filter?
Filters (filter) is an object that can convert a request or corresponding header and body content. Filters are different from Web Components because filters are not usually responsible for creating a response. Instead, the filter provides functionality that can be "attached" to any web resource. Filters can accomplish the following major tasks:
(1) Query the request and do the appropriate operation.
(2) blocking requests-corresponding pairs so that they cannot be passed further.
(3) modify its request header and data. Users can complete tasks by providing a customized version of the request.
(4) Modify the response header and data. Users can complete the task by providing a customized version of the response.
(5) Interacting with external resources.

two. In order to deal with HTTP services, which servlet classes need to be extended in Java source code?
To handle HTTP services, you need to extend the HttpServlet class in Java source code and rewrite the Doget () and Dopost () methods to implement this component.

three. How do I define a filter in Java source code? The
(1) refers to the filter interface in which the Javax.servlet package implements.
(2) Implementing the filter interface requires overriding the Dofilter (servlet Request req, servlet Response res, Filterchain chain) method. The
(3) Specifies the filter mappings in Web.xml.

four. Describe the lifecycle of the servlet in detail?
servlet lifecycle: servlet load-> instantiation-> service-> destroy.
(1) servlet loading phase: The servlet container mounts a servlet when the following conditions occur,
The ①servlet container automatically mounts certain servlet when it is started, and implements it only in the Web.xml file <servlet > Add code between </Servlet> tags <loadon-startup>1</loadon-startup>;
② after the Servlet container starts, The customer sends the request to the servlet for the first time, and the servlet is reloaded after the
③servlet class file is updated.
(2) instantiation phase: After the servlet is loaded, the servlet container creates a servlet instance and invokes the Init () method of the servlet to initialize. Within the entire lifecycle of the servlet, the init () method executes only once.
(3) Service phase: Invoke Service () method, which is the core of the servlet, responsible for responding to customer requests. Whenever a client requests a HttpServlet object, the service () method of the object is invoked and passed to the method a request (ServletRequest) object and a response (Servletresponse) object as an argument. The service () method already exists in HttpServlet, and the default services function is to invoke the Doget or Dopost method corresponding to the HTTP request method to respond to the user.
(4) Destroy phase: When a Web application is terminated, or if the servlet container terminates, or when the servlet container remount A new instance of the servlet, the servlet container invokes the servlet's Destroy () method, which executes only once. In the Destroy () method, you can release the resources that the servlet occupies. A servlet may produce additional threads when it runs the service () method, so it is necessary to confirm that the threads have been terminated or completed when the Destroy () method is invoked.

Five. How to drive the filter chain in Java source code (filter chain)?
Two filters, Encodingfilter is responsible for setting the encoding, Securityfilter is responsible for controlling the permissions, the server will be in accordance with the Web.xml filter defined sequentially into a chain, and then execute one of the Dofilter () method.
The sequence of code executed is:
(1). Performs the part before the first filter encodingfilter.dofilter () Chain.dofilter (), request.setcharacterencoding (encoding);
(2) to perform the part of the second filter Securityfilter.dofilter () before Chain.dofilter (): To determine whether the user is logged in. If the user is logged in, the requested resource is accessed, and if the user is not logged on, the page is redirected to:/failure.jsp.
(3). Performs the part after the Chain.dofilter () in the second filter Securityfilter.dofilter ().
(4). After performing the part of the first filter Encodingfilter.dofilter () chain.dofilter (): Write to the completed log, and finally return the response.

Chapter 4
What is a unified expression language?
The Unified expression language (Unified EL) represents the union of the Expression Language (EL) provided by JSP2.0 and the expression language created by version 1.0 of the JSF (component-based Java Web application framework model) technology, and its main features are:
1. Dynamically read the data stored in the JavaBean components in the different structure and implicit objects;
2. Dynamically writes data to the JavaBean component;
3. Invoke arbitrary static and public methods;
4. Perform arithmetic operations dynamically.

two. Enumerate the properties of the JavaBean component?
In JavaBean design, the different roles of attributes are divided into four categories: simple properties, indexed properties (Indexed property), association properties (Bound property), and restriction attributes (constrained property).

three. Give the definition and syntax of immediate evaluation and delay evaluation expressions?
(1) Immediate evaluation
Defined:
The JSP engine evaluates the expression and returns the result as soon as the page is called for the first time.
Grammar:
All expressions that use the ${expr} symbol are executed immediately;
Can be used only in HTML template data or as a JSP Tag property value that can use run-time expressions, for example:

<c:out value= "${sessionscope.username}"/>

(2) Deferred evaluation
Defined:
After the page life cycle, the expression is deferred through some mechanism of the underlying technology until the appropriate point in the lifecycle occurs.
Grammar:
The delay evaluation expression is formatted as #{expr};
Can be computed at any other stage of the page lifecycle defined using the expression technology. For example:

 

four. Describe JavaBean's design habits? The
JavaBean Component Design Convention is responsible for managing the properties of classes and managing the public methods that provide access to those properties. The JavaBean component can be:
(1) Read/write, read-only, or write-only,
(2) simple, meaning that it contains a value, or an index (indexed) attribute, which means that it represents an array of values. The
attribute does not have to be implemented by an instance variable and must be accessed using public methods that follow the following specifications:
① for each readable attribute, the bean must have a method of the following form.
Propertyclass GetProperty () {...}
② for each writable attribute, the bean must have methods in the following form.
SetProperty (Propertyclass pc) {...}
In addition to the attribute method, the JavaBean component must be a public common class, and a constructor without any arguments must be defined. In addition, an attribute is set to private.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.