Chinaunix首页 | 论坛 | 博客
  • 博客访问: 523868
  • 博文数量: 151
  • 博客积分: 7010
  • 博客等级: 少将
  • 技术积分: 1405
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-22 14:32
文章分类

全部博文(151)

文章存档

2011年(1)

2010年(23)

2009年(1)

2008年(126)

我的朋友

分类: 系统运维

2008-07-31 11:21:57

Scripting elements let you add small pieces of code in JSP page,such as an if statement.The scripting code must be written in the language defined by the page directive.

一、Declaration
Declarations are used to declare scripting language variables or methods.

Syntax
<%! declaration %>

Example
<%! int globalCounter = 0; %>


二、Expression
An expression is used to add the result of executing a scripting expression to the response. The content between the start and the end characters must be a complete valid expression in the language defined by the page directive that results in a string or can be converted to a string. All JSP implicit scripting variables are visible in an expression element.

Syntax 1: In a regular JSP page
<%= expression %>

Example
<%= globalCounter++ %>

三、Scriptlet
Scriptlets are used to embed scripting code fragments in a page. The content must be a code fragment in the language defined by the page directive.

Syntax
<% scripting code fragment %>


Example
<% java.util Date clock = new java.util.Date(  ) %>
<% if (clock.getHours(  ) < 12) { %>
  Good morning!
<% } else if (clock.getHours(  ) < 17) { %>
  Good day!
<% } else { %>
  Good evening!
<% } %>
阅读(588) | 评论(0) | 转发(0) |
0

上一篇:Directive Elements

下一篇:Action Elements

给主人留下些什么吧!~~