由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - JSP translation unit?
相关主题
JSP tag file and EL warnings请教一下JSP+SERVLET结构的进阶教材,多谢了
使用JAVA的一则经验和教训JB JAVA Bean,SERVLET位置一问
jBuiler 4白皮书(来自inprise网站)JSP+SERVLET网站一般用下面方式来保存和传递变量和参数
Swing GUI vs JSP Web SolutionJSP/SERVLET里面如何实现弹出窗口(新短信)功能
help needed请问JSP/SERVLET和MYSQL如何实现照片上载和调用
找在servlet里处理上传文件的包web service + JSP/Servlet tutorial
怎么在servlet里得到请求JSP的相对路径?JSP一问
[转载] 请推荐关于Servlet和JSP编程的书Servlet里面怎样简单设置数据库路径
相关话题的讨论汇总
话题: jsp话题: unit话题: include话题: dynamic
进入Java版参与讨论
1 (共1页)
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.

1 (共1页)
进入Java版参与讨论
相关主题
Servlet里面怎样简单设置数据库路径help needed
问一个J2EE和Tomcat问题找在servlet里处理上传文件的包
JSP的一个问题怎么在servlet里得到请求JSP的相对路径?
J2EE和未来工作问题[转载] 请推荐关于Servlet和JSP编程的书
JSP tag file and EL warnings请教一下JSP+SERVLET结构的进阶教材,多谢了
使用JAVA的一则经验和教训JB JAVA Bean,SERVLET位置一问
jBuiler 4白皮书(来自inprise网站)JSP+SERVLET网站一般用下面方式来保存和传递变量和参数
Swing GUI vs JSP Web SolutionJSP/SERVLET里面如何实现弹出窗口(新短信)功能
相关话题的讨论汇总
话题: jsp话题: unit话题: include话题: dynamic