The orders to compile jsp

来源:互联网 发布:ubuntu su 认证失败 编辑:程序博客网 时间:2024/04/29 13:56

(The Information is from http://www.jguru.com/faq/view.jsp?EID=421448. If any question, pls tell me to delete it immediately. )

When a jspcompiler compiles the jsp page, in what order does it get compiled?Specifically if I have scriptlets ,tags, includes and expressions, whatwould be the order of compilation for these four. Is there a documentsomewhere that defines this?

The answer:

The order of compilation it's really based on the jsp page itself.
The JSP page is converted to a java source file. This is done insertingthe "content of the page" inside a skeleton. The order is the sameorder that you have in the page.

Let's suppose that in the page there are:

1) a scriptlet
2) a custom tag
3) static html
4) a jsp:include
5) an expression
6) an page include

the java generated file will contain:

1) the scriptlet code
2) the custom tag creation; all attributes are converted to tag setters
3) static html will be converted with something similar to response.getWriter().write(<the static html>)
4) the call for including the external file
5) the expression converted to java code for output
6) the content of the included page inserted in the java code.

As you can see, there is no specific order. Once the java source fileis created, the compiler takes care of generating the servlet code,following the normal process.