当前位置:网站首页>Summary of web development technology knowledge

Summary of web development technology knowledge

2022-06-21 14:12:00 Enthusiastic little fans

One 、 Basic concepts

1)jsp:Java Server Page--web Server design criteria , Dynamic website

2)web:world wide web abbreviation www web

3)url: Uniform resource identifiers ( website )= Name of agreement + Host name / domain name /IP Address + file name ( Inclusion path )

http: Hypertext transfer protocol

https And http The difference between :https It's about security http passageway , yes http Security version , stay http Add socket under SSL layer , Encrypt the transmission page .

Two 、JSP

1)JSP And Servlet

JSP The designed dynamic web page mainly realizes the display function ,JSP It's a server-side scripting language , To reduce the Servlet The difficulty of using . It provides Servlet All the functions that can be realized ,JSP Is translated into Servlet Before compiling and running .

Servlet The designed dynamic web page mainly realizes the control function .

2)JSP Command elements

<%@ Instruction names attribute 1=" Property value 1" attribute 2=" Property value 2" … %>

   page Instructions : Define the global properties of the entire page

    Design JSP Program (ch03_3_page.jsp), Show ( The server ) The current time of the system .

  Because you want to use a date class object , therefore , Must from page Command import java.util.Date class , meanwhile , Because Chinese characters are used in the page , You need to use a code that supports Chinese characters , Here the “UTF-8” code , therefore , need page Instruction assignment

contentType="text/html" 

pageEncoding="UTF-8"

import="java.util.Date"

   

include Instructions : Used to include a file

 taglib Instructions : Reference third-party tag libraries

3)JSP Action elements

The action element belongs to the server side JSP Elements , It is used to mark and control JSP The behavior of the engine

JSP The first phase of the page lifecycle is the transformation phase , In this phase JSP The page is converted to contain the corresponding Servlet Of Java file , The container will... According to the following rules JSP The elements in are converted to Servlet Code :

  • There are some Instructions During the transition phase Java Code , for example page The directive import Attributes generate Servlet Class import sentence . Some instructions simply tell the container about the overall nature of the page , for example page The directive contentType Property specifies the content type of the response ,session Property specifies whether the page participates in HTTP conversation .

  • be-all JSP Statement , All become generated Servlet Part of class , They are copied as is . The variables declared in this way become instance variables , Declared methods become instance methods .

  • all JSP Script , All become _jspService() Part of the method , They are also copied as is . So the variables declared in the script become _jspService() Method's local variables , You cannot declare a method in a script , Because in Java A method cannot be defined in a method in a language !!

  • be-all JSP expression , All become _jspService() Part of the method , The value of the expression uses out.print() Statement output .

  • be-all JSP action Are replaced by vendor specific classes .

  • all Expression language EL Use after calculation out.write() Statement output .

  • All template text , All become _jspService() Part of the method , Template content usage out.write() Statement output .

  • be-all JSP notes All ignored

  • stay JSP The conversion phase of the page , The container in _jspService() Method to declare and initialize some variables , Can be in JSP These variables are used directly in page scripts or expressions . These variables are objects created by the container , So it's also called Implicit or built-in objects .

matters needing attention :

  • because JSP The variables and methods defined in the page declaration become generated Servlet Class members , So the order in which they appear on the page doesn't matter .

  • Because the script will be converted to Servlet Of _jspService() Part of the method , Therefore, the variables declared in the script become local variables of the method , So the order in which they appear is very important . The following code will not be compiled

        <%  String s=s1+s2; %>    //s2 Used before a declaration

        <%! String s1="hello"; %>

        <%  String s2="hello"; %>

        <%  out.print(s); %>

  • stay Java In language , Instance variables are automatically initialized to default values , Local variables must be explicitly assigned before they are used . So in JSP The variables declared in the declaration are initialized to the default value , The variables declared in the script must be explicitly initialized before use .

  • It should be noted that , Instance variables are instantiated in the container Servlet Is created and initialized only once , So in JSP Variables declared in the declaration keep their values throughout multiple requests , Local variables are created and destroyed for each request , Therefore, variables declared in the script do not maintain their values in multiple requests , But in JSP Every time the container calls _jspService() Method is reinitialized

原网站

版权声明
本文为[Enthusiastic little fans]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221428064129.html