BBS水木清华站∶精华区

发信人: agents (智能代理), 信区: Java        
标  题: JSP语法(5) 
发信站: BBS 水木清华站 (Tue Jan  2 14:48:40 2001) 
 
5 【Scriptlet】   
   
  Contains a code fragment valid in the scripting language used in the page. 
 
 
 ▲ [JSP Syntax] 
 
     <% code fragment %> 
 
▲  [Examples] 
 
<% 
 String name = null; 
 if (request.getParameter("name") == null) { 
%> 
<%@ include file="error.html" %> 
<% 
  } else { 
    foo.setName(request.getParameter("name")); 
    if (foo.getName().equalsIgnoreCase("integra")) 
    name = "acura"; 
    if (name.equalsIgnoreCase( "acura" )) { 
%> 
 
▲ [Description] 
 
   A scriptlet can contain any number of language statements, variable  
   or method declarations, or expressions that are valid in the page scripting 
   language. 
 
   Within scriptlet tags, you can do any of the following: 
 (1) Declare variables or methods to use later in the file  
    (see also Declaration) 
 
 (2) Write expressions valid in the page scripting language  
    (see also Expression). 
 
 (3) Use any of the JSP implicit objects or any object declared with  
     a <jsp:useBean> tag. 
 
 (4) Write any other statement valid in the page scripting language  
    (if you use the Java programming language, the statements must conform  
     to the Java Language Specification). 
 
 (5) You must write plain text, HTML-encoded text, or other JSP tags outside  
     the scriptlet. 
 
    Scriptlets are executed at request time, when the JSP engine processes  
    the client request. If the scriptlet produces output, the output is stored 
    in the out object, from which you can display it. 
 
-- 
 
※ 修改:·agents 於 Jan  2 15:33:04 修改本文·[FROM:   166.111.54.22] 
※ 来源:·BBS 水木清华站 smth.org·[FROM: 166.111.54.22] 

BBS水木清华站∶精华区