javaweb-JSP (a)

First, what is JSP

  JSP stands for java Servlet Pages, and it servlet technology, are defined by SUN for the development of dynamic web technology resources. JSP biggest feature of this technology is that, as written in jsp write html, but in terms of the relative html, html only provide static data for the user, while JSP technology allows nested java code in the page to provide users with dynamic data .

Two, JSP principle

2.1, web server how to invoke and execute a JSP page?

  Browser sent a request to the server you are, no matter what access the resources, they are actually accessing Servlet, so when accessing a jsp page, is actually visiting a Servlet, jsp server at the time of execution, the first to translate into a jsp Servlet, so when we visit jsp, in fact, not when accessing jsp, in fact, are not accessing jsp, but in the Servlet access jspl after translation, for example, the code below:

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>First Jsp</title>
</head>
<body>
    <h1>Jsp</h1>
    <%
        String s = "Hello Jsp";
        out.print(s);        
    %>
</body>
</html>

 

 

  

 

      

  

Guess you like

Origin www.cnblogs.com/sacai/p/11619664.html