Thursday, July 22, 2010

JSP page translation of the principle of



As we all know, every JSP page will be compiled into a Java Web container class for the Web container calls, and generates HTML foliage back to the user. And understand the methods and rules which the variation of our study is very good for JSP, you can say that learning this good compiler theory, we have learned a good knowledge of most of the JSP, and the rest of the work will only memorize Yi Xie tablib and repeated applications to make themselves more skilled it was.

First look at the JSP page corresponding to the basic structure of Class. Every JSP page will be compiled into a format like the following, first give a general impression, detailed instructions in the back

This is the most important function which is pageservice, web containers in a compiled JSP classes after the application of this class of objects, and direct calls to pageservice to get the Response, the last returned to the customer. As the details, we can summarize as follows:

1. All the JSP page translation out of class, all inherited from the HttpJspBase and named PageName $ jsp.

2. In the first call pageservice function of time, the class will be repeated initialization, and this initialization function is _jspx_init, if we want, we can customize this function to achieve the initialization of JSP page .

3. This code is converted into what?

This code is directly converted into Java code into pageservice function inside.

4. This code is converted into what?

This code is translated into the member functions and member variables, that is, those statements in the JSP life cycle are present.

5.HTML code?

PrintWriter html code to be written directly inside the feedback to the user, very direct.

6. Why JSP page translation method to write so many provinces, such as session, out, page, context and the like.

These are defined in pageservice temporary variable inside the specific initialization code can refer to the example above, each call to JSP pages, these variables will be re-initialized once. Of course, we can easily declare their variables.

7. Province was so understandable way?

This province was obtained by way of calling doSomething Object's toString (), and then write out directly inside. Equivalent to:

out.print (object.doSomethiing (). toString ())

8.JavaBean scope inside the scope of the definition of the scope, the scope of the meaning here?

This is the Bean object handle to save the meaning of the place. We can imagine a range of Bean is pageservice page inside a local variable, when the end of the first treatment, this variable will be Java virtual machine recovery. The session variable. The request level of Bean JSP page should be a member variable. The session and the application can not be kept inside the JSP page class, but should be kept in the call object inside the JSP page.

9. On command, this would be very simple, just a one corresponding to the response.setContentType () statement only.

10. Turn on the JSP page translation of the problem. This statement is translated into getServletContext (). GetRequestDispatcher ("/ List.jsp"). Forward (req, res); statement.

11. Encountered this statement, JSP translator will put the file code and file code now and then mixed with the compiler, generates JSP class. This method is very good, allows us to document the style of uniform, such as it written in a file header, and the footer is also written as a JSP, and the index.html file which contains these two recently, so, regardless of Content how they change, do not become the upper and lower style is conducive to the unity of style.

These are simple JSP page of the translation process and more details for it can refer to the tomcat source code to understand these principles Duiyu learning JSP Laishui, is very important to Dada's 鎻愰珮 the efficiency of learning.







相关链接:



Alibaba Ma: Even if I have to finally kneeling down



Matroska Format



FTP Site Preferences



Astronomy WIZARD



Easy Computer Education



ESRI experts, non-Chan: Snow Emergency GIS can do more



Photoshop font effects - Cotton words



Premier Science - SCREEN Savers



Hope PS3 Mobile CONVERTER



mp3 to mp4



Wang Zhuo: LANDesk Chinese "master" (1)



convert vob to flv



8-year restructuring Neusoft normalized



Mkv File?



1 comment: