Tags commonly used in jsp

Jsp is essentially a servlet, but tomcat will translate it into a servlet, servlet is essentially a class, then jsp is also a class. Various tags in jsp will be translated into various basic java codes by tomcat

If a variable is defined in a jsp page, it can be obtained directly in another place, for example

<%
		String name = "zhangsan";
%>
	
<%= name  %>

 

But please pay attention, the current development does not write java code in jsp, the above is java code, and now it is the tag that needs to use jsp. What is the jsp tag? The following example

1. $tag (el tag)

	<%
	
		pageContext.setAttribute("name", "lisi");
	%>
	
	${name } 


    output result: lisi

      If you want to use the el($) tag directly in jsp, you need to put the variable in the four domains, and then you can get it directly. This is the rule of the el tag. The java code above just puts the variable into the field, and then you can get it directly. The four domains are

page , request , session , application. The page domain can only be obtained in this jsp page, and the request domain can be obtained in one request. If request forwarding is used, redirection cannot be used in request. session represents a session,

A session is when a browser is opened and a session is created. The application is the domain placed on the server. As long as the server is open, this domain can be obtained anywhere.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324972882&siteId=291194637