y********o 发帖数: 2565 | 1 I googled a little bit, most of the hits are interview-related, and don't
explain it very well.
I checked Marty Hall's book, but could not find anything helpful.
Any hint is highly appreciated. | m******t 发帖数: 2416 | 2 you mean jspc - the thing that's supposed to translate jsp to java? | A**o 发帖数: 1550 | 3 or you mean each unit of text on the browser that needs to be translated
into another language? | y********o 发帖数: 2565 | 4 Ok, thx.
I got the following from http://www.techinterviews.com/?p=92 , but honestly, I don't quite understand the explanation. In particular, is a translation unit necessarily related to jsp include?
What is a translation unit? JSP page can include the contents of other HTML
pages or other JSP files. This is done by using the include directive. When
the JSP engine is presented with such a JSP page it is converted to one
servlet class and this is called a translation unit, Things to remember in | m******t 发帖数: 2416 | 5 Oh, I see. Well, it's not necessarily directly related but if you understand
it, it'll help a lot in understanding how jsp include works, especially the
distinction between static and dynamic include. | y********o 发帖数: 2565 | 6
understand
the
Yes, I think I understand jsp include, be it static or dynamic. But what
exactly is a translation unit?
【在 m******t 的大作中提到】 : Oh, I see. Well, it's not necessarily directly related but if you understand : it, it'll help a lot in understanding how jsp include works, especially the : distinction between static and dynamic include.
| m******t 发帖数: 2416 | 7 Well, from the quote you posted,
"When the JSP engine is presented with such a JSP page it is converted to
one servlet class and this is called a translation unit, ..."
I guess that's what a translation unit is. 8-)
If I understand it correctly, what it's trying to say is that when you have
static includes, they are dealt with at translation time, hence become part
of the same translation unit formed by the jsp including them.
Don't know whether the concept makes sense with request-time includes | y********o 发帖数: 2565 | 8
have
part
Yes, all JSP pages are converted into Servlet, right?
How about this, does a single JSP page without any include elements
constitute a translation unit?
How many translation units are there if a JSP page has one dynamic include?
How many translation units are there if a JSP page has one static include?
Maybe answers to these questions will crack the mystery.
【在 m******t 的大作中提到】 : Well, from the quote you posted, : "When the JSP engine is presented with such a JSP page it is converted to : one servlet class and this is called a translation unit, ..." : I guess that's what a translation unit is. 8-) : If I understand it correctly, what it's trying to say is that when you have : static includes, they are dealt with at translation time, hence become part : of the same translation unit formed by the jsp including them. : Don't know whether the concept makes sense with request-time includes
| g*****g 发帖数: 34805 | 9 Is this important at all? To be honest, I've been
developing JSP for 7 years, and I don't know the answers.
【在 y********o 的大作中提到】 : : have : part : Yes, all JSP pages are converted into Servlet, right? : How about this, does a single JSP page without any include elements : constitute a translation unit? : How many translation units are there if a JSP page has one dynamic include? : How many translation units are there if a JSP page has one static include? : Maybe answers to these questions will crack the mystery.
| y********o 发帖数: 2565 | 10 I was asking myself this question, too. But, you know what, some stupid recr
uiters search the web and do ask this question.
【在 g*****g 的大作中提到】 : Is this important at all? To be honest, I've been : developing JSP for 7 years, and I don't know the answers.
| m******t 发帖数: 2416 | 11
I would think so. The criteria is pretty clear - whatever gets compiled into
one servlet is one unit. So any single jsp, as long as it's not included by
another (i.e. not a jsp fragment), it's a translation unit.
Dynamic includes get "included" at request-time, so they don't have to do
with translation at all.
Still one, I would think. A spec compliant jsp compiler would include the
fragment verbatim, and then do the compilation.
【在 y********o 的大作中提到】 : I was asking myself this question, too. But, you know what, some stupid recr : uiters search the web and do ask this question.
| y********o 发帖数: 2565 | 12
into
by
OK, so, sounds like only when there are dynamic includes, there are more
than 1 translation units. Otherwise 1 translation unit only.
【在 m******t 的大作中提到】 : : I would think so. The criteria is pretty clear - whatever gets compiled into : one servlet is one unit. So any single jsp, as long as it's not included by : another (i.e. not a jsp fragment), it's a translation unit. : Dynamic includes get "included" at request-time, so they don't have to do : with translation at all. : Still one, I would think. A spec compliant jsp compiler would include the : fragment verbatim, and then do the compilation.
| m******t 发帖数: 2416 | 13
Well... you could say that, and nobody can say you are wrong, but there is
the subtle point that a dynamic include can in fact be including the
response of any URL, which isn't necessarily a JSP, or, in turn, a "
translation unit" at all.
In fact, we all need to be a little careful with the terms "static" and "
dynamic" here. There is the "static vs. dynamic" as in "a static html page
vs. a dynamic jsp", and then there is the "translation-time vs. request-time
" as in "a jsp gets translated int
【在 y********o 的大作中提到】 : : into : by : OK, so, sounds like only when there are dynamic includes, there are more : than 1 translation units. Otherwise 1 translation unit only.
|
|