JSP technology

JSP技术的主要特点有:

  • A language for developing JSP pages, which are text-based documents that describe how to process a request and construct a response

  • An expression language for accessing server-side objects

  • Mechanisms for defining extensions to the JSP language

JSP的生命周期(The life cycle of a JSP page)

1.Tanslation and Compilation(翻译和编译)

当一个请求(Request)被映射到一个JSP页面,Web Container首先检查这个JSP页面的Servlet是否比JSP页面旧。如果是,Web Container首先将JSP页面翻译成Servlet类,并编译成.class文件。During development, one of the advantages of JSP pages over servlets is that the build process is performed automatically.

在翻译阶段,各种不同类型的数据以不同的方式处理。静态数据直接输入到response stream里。JSP element处理方式如下:

  • Directives(伪指令)用来指示Web Container怎样处理和执行JSP页面。
  • Scripting elements被插入到JSP页面的Servlet class中。
  • Expression language expressions are passed as parameters to calls to the JSP expression evaluator.
  • jsp:[set|get]Property elements are converted into method calls to JavaBeans components.
  • jsp:[include|forward]elements are converted into invocations of the Java Servlet API.
  • The jsp:plugin element is converted into browser-specific markup for activating an applet.
  • Custom tags are converted into calls to the tag handler that implements the custom tag.

 Both the translation and the compilation phases can yield errors that are observed only when the page is requested for the first time. If an error is encountered during either phase, the server will return JasperException and a message that includes the name of the JSP page and the line where the error occurred.

After the page has been translated and compiled, the JSP page’s servlet (for the most part) follows the servlet life cycle described in Servlet Life Cycle:

  1. If an instance of the JSP page’s servlet does not exist, the container:

    1. Loads the JSP page’s servlet class

    2. Instantiates an instance of the servlet class

    3. Initializes the servlet instance by calling the jspInit method

  2. The container invokes the _jspService method, passing request and response objects.

If the container needs to remove the JSP page’s servlet, it calls the jspDestroy method.

2.Execution

You can control various JSP page execution parameters by using page directives.

 

原文Javaee 5 tutorial.

转载于:https://www.cnblogs.com/cuillgln/archive/2012/05/03/2479680.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值