Learn the small summary of the early understanding of Java

Source: Internet
Author: User
Java


always think that the tutorial writing is very good, but very fragmented, so that beginners to no avail.


This article on the author to study a period of the Java EE and combine this book to write something.


1. International


, for example, I have a resource kit called Messages_*.properties.


Management client:


public bankadmin (Locale Currentlocale)


messages = Resourcebundle.getbundle ("Messages", Currentlocale);


Web Client:


Extracts the zone information from the request (by the browser's language preferences), opens the corresponding resource bundle, and stores the package as a session property:


resourcebundle messages = (resourcebundle) session.getattribute ("Messages");


if (messages==null) {


Locale Locale = Request.getlocale ();


messages = Resourcebundle.getbundle ("Messages", locale);


Session.setattribute ("messages", messages);


}


Note: In order to display Chinese, the part of the program needs to choose the specified font, such as "MS Song" when displaying Chinese, otherwise the interface will be a box.


2.Context is an interface (all named operations are related to it), InitialContext is a class that inherits directly from Object


3.RequestDispather


accepts client requests and sends resources to any server to wrap Servlets but the servlet container can generate requestdispatcher to encapsulate any type of resource.

Several important tabs in the
4.deploytool


The first thing to note is that not all tabs are useful for each component.


1). Env. Enties Environment Entry, setting environment variables (which are irrelevant to program logic and frequently changing content), invoking environment variables through Jndi naming,


ic.lookup ("java:comp/env/variable name"). stored in the Enterprise bean's configuration descriptor, allows you to customize the business logic of the enterprise bean without altering the source name value pairs.


2). The EJB Refs enters the application name of the enterprise bean in coded name. is the logical name of the Jndi lookup client. If you look for enterprise bean applications in Jndi lookup like this





Java:comp/env/ejb/otherbean


then enter Ejb/otherbean


3). Resource Refs


Resource Reference name is the logical name of the resource that the Jndi lookup is. There are six types of:


DataSource is jdbc/
.

Session mail/


URL url/


queueconnectionfactory and Topicconnectionfactory jms/


connectionfactory env/


Note: queueconnectionfactory and topicconnectionfactory,connectionfactory require user name and password, please write to username and password domain,


Cloudscape does not require a username and password.


4). Resource Environment Refs


for
that appear jms/in code

5. If the component has a local entity Bean applied, the name of the referenced bean needs to be given in the Enterprise Bean Name field.


6. Object references for passing enterprise Beans


For example, you can refer to a method that enables an enterprise bean to invoke another enterprise bean. You cannot access this reference because it points to a bean instance running in the EJB container, only the container can


to directly invoke the method of the bean instance. The client implements the method of indirectly invoking the bean through the remote interface, and the reference enterprise bean of these objects (the remote interface implements the object) can
each other

visit.

The
session Bean invokes the Getejbobject method defined by the Sessioncontext interface to obtain its remote interface object reference.

The
entity Bean invokes the Getejbobject method defined by the Entitycontext interface.


These two pretexts provide an enterprise bean to access the context object managed by the EJB container.


Typically, an enterprise bean saves its context object through the Setsessioncontext method. The following code fragment illustrates how the session bean uses these methods:


public class Wagonbean implements Sessionbean {


   


Sessioncontext context;


   ...


public void Setsessioncontext (Sessioncontext SC) {


This.context = SC;


   }


   ...


public void Passiton (basket basket) {


   ...


Basket.copyitems (Context.getejbobject ());


   } 


7.meta-inf must be in uppercase.


8.include (request,response) Purpose: To add a resource.


The responses returned from the Web component include, for example, copyright and labeling information


resources are divided into: static and Web Components


9.service Service method usual mode


extract information from the request--access to external resources--and then publish the response based on that information


Release Response steps: 1. Response first 2. Output flow from response 3. Write the response body in the output stream


10. It is the most direct means to see his help for a tool that is not understood, nothing else can be compared.





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.