⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 5.htm

📁 一个不错JSP入门教程.
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0042)http://www.aspcn.com/showarticle.asp?id=81 -->
<HTML><HEAD><TITLE>jsp</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content="MSHTML 5.00.2920.0" name=GENERATOR><LINK href="5.files/aspcn.css" 
rel=stylesheet type=text/css></HEAD>
<BODY>
<table border=0 width="100%">
  <tbody> 
  <tr> 
    <td>5 
      <h2 align=center>Scriptlet</h2>
      <p>包含一个有效的程序段. </p>
      <a name=10998></a> 
      <h4>JSP 语法</h4>
      <blockquote>&lt;% <em>code fragment</em> %&gt; </blockquote>
      <a 
                  name=16389></a> 
      <h4>例子</h4>
      <blockquote><strong>&lt;% <br>
        &nbsp; &nbsp; &nbsp; String name = null; <br>
        &nbsp; &nbsp; &nbsp; if (request.getParameter("name") == null) { <br>
        %&gt; <br>
        </strong>&lt;%@ include file="error.html" %&gt; <br>
        <strong>&lt;% <br>
        &nbsp; &nbsp; &nbsp; } else { <br>
        &nbsp; &nbsp; &nbsp; foo.setName(request.getParameter("name")); <br>
        &nbsp; &nbsp; &nbsp; if (foo.getName().equalsIgnoreCase("integra")) <br>
        &nbsp; &nbsp; &nbsp; name = "acura"; <br>
        &nbsp; &nbsp; &nbsp; if (name.equalsIgnoreCase( "acura" )) { <br>
        %</strong><strong>&gt; </strong></blockquote>
      <a 
                  name=11059></a> 
      <h4>描述</h4>
      <p>一个scriptlet能够包含多个jsp语句,方法,变量,表达式 </p>
      <p>因为scriptlet,我们便能做以下的事: </p>
      <ul>
        <a name=16712></a> 
        <li>声明将要用到的变量或方法(参考 <a 
                    href="http://www.aspcn.com/syntaxref11.fm3.html#10983">声明</a>).&nbsp; 
        <li>编写JSP表达式(参考 <a 
                    href="http://www.aspcn.com/syntaxref11.fm4.html#11258">表达式</a>).&nbsp; 
        <li>使用任何隐含的对象和任何用&lt;jsp:useBean&gt;声明过的对象 
        <li>编写JSP语句 (如果你在使用Java语言,这些语句必须遵从<em>Java Language Specification,</em>). 
        <li>任何文本,HTML标记,JSP元素必须在scriptlet之外 </li>
      </ul>
      <p>当JSP收到客户的请求时,scriptlet就会被执行,如果scriptlet有显示的内容,这些显示的内容就被存在out对象中。</p>
    </td>
  </tr>
  <tr> 
    <td>所有文章来自<font color=red>http://www.aspcn.com &nbsp; ASP中华网</font>如要转载请注明出处,谢谢</td>
  </tr>
  </tbody> 
</table>
</BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -