" tag. The code segment within this tag can define variables, call methods, expression operations and other operations, and will run and generate corresponding actions when the web service requests it."/> " tag. The code segment within this tag can define variables, call methods, expression operations and other operations, and will run and generate corresponding actions when the web service requests it.">

Home  >  Article  >  What is the code snippet in jsp

What is the code snippet in jsp

anonymity
anonymityOriginal
2019-05-06 10:25:003694browse

The code segment in jsp is also called the script segment. The script segment is a JSP code snippet or script snippet, embedded in the "a4558806285d5b7820bdaa0b90aa4d26" tag. In the script segment, you can define variables, call methods and perform various expression operations. Add a semicolon after each line of statements (because the Java code embedded in a4558806285d5b7820bdaa0b90aa4d26 is no different from our ordinary Java code. This is expression is different).

Use JSP script elements to embed Java code into the JSP page. These Java codes will appear in the Servlet generated by the current JSP page, allowing JSP to separate static content from dynamic content. This Java code is run when the web server responds to a request. Surrounding the script segments can be raw HTML or XML statements, where the snippet can create conditional execution of code, or call another piece of code.

What is the code snippet in jsp

The script segment uses the following format:

<% Java代码 %>

For example:

<%@ page language="java" contentType="text/html;charset=utf-8"
   pageEncoding="utf-8"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Insert title here</title>
</head>
<body>
         <%!
                   //int number =0;//声明计数变量number
                  
         %>
         <%
                   //this.add();//该脚本程序调用定义的计数方法
                   int number =0;//声明计数变量number
         %>
         本网页的访问次数是:<%=++number %>次。
</body>
</html>

The above is the detailed content of What is the code snippet in jsp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What does ne mean in jspNext article:What does ne mean in jsp