Home > Java > javaTutorial > what is jsp expression

what is jsp expression

(*-*)浩
Release: 2020-09-15 15:54:57
Original
10049 people have browsed it

The JSP expression becomes the outprint() method after the page is converted into a Servlet. Therefore, the JSP expression has the same function as the out.print() method embedded in the scriptlet in the JSP page. If an object is output through a JSP expression, the object's toString() method will be automatically called, and the expression will output the content returned by the toString() method.

Recommended course: Java Tutorial.

what is jsp expression

Expression is used to output information on the page. Its usage format is as follows:

<%=变量或可以返回值的方法或 Java 表达式%>
Copy after login

Pay special attention to the "< There should be no space between %" and ".

JSP expressions can be applied to the following situations.

Output content to the page:

<% String name = "www.123.com"; %>
用户名:<%=name%></p>
<p>The above code will generate the following running results: </p>
<pre class="brush:php;toolbar:false">用户名:www.123.com
Copy after login

Generate a dynamic link address :

<% String path = "welcome.jsp"; %>
<a href="<%=path%>">链接到welcome.jsp</a>
Copy after login

The above code will generate the following HTML code:

<a href="welcome.jsp">链接到 welcome.jsp</a>
Copy after login

Dynamicly specify the Form form processing page

<% String name = "logon.jsp"; %>
<form action="<%=name%>"></form>
Copy after login

The above code will generate The following HTML code:

<form action="logon.jsp"></form>
Copy after login

Name the elements generated by the loop statement

<%for(int i=1;i<3;i++) 
{
%>
file<%=i%>:
<input type="text" name="<%="file"+i%>"><br>
<%}%>
Copy after login

The above code will generate the following HTML code:

file1:<input type="text" name="file1"><br>
file2:<input type="text" name="file2"><br>
Copy after login

The above is the detailed content of what is jsp expression. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
jsp
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template