Some basic knowledge of JSP and Servlet is collated for memo.
First, the basic relationship between JSP and Servlet 1, jsp-->web container-->servlet--> loaded into the container of the virtual machine execution--output execution results to the browser side in this process, all the values outside of <%%>, is considered to be a direct output of the content in Out.println (). Detailed understanding of the code
The above code and the following code one meaning
// example Description: Servlet and JSP relationships Boolean b = false ; if (b) { out . println ( " Here is the content one " else { Out . println ( " Here is the content two " ); %> <body> this is my JSP Page. <br> </body>
<%%> all characters outside of the tag, the JSP Web container will not be handled specially, but simply put into the output stream out (printwriter) output to the browser
The contents of the tag are Java code, and when the Web container finishes processing, the results are returned to the browser
All characters outside the label and in the tag are processed by the Web container, resulting in an HTML file, which is the final file received by the browser
2. Implementation instructions
Order: Browser Request-->jsp file-->web Server--parse JSP as Java file--and container J re check Java file for compile error--compile Java file, get. class file-- JVM Load execution--response browser
When a web container resolves a jsp, it is generally first to check if a file such as the latest (which indicates that the JSP file has not been changed) has been servet.class, and if so, do not recompile the JSP file, or recompile the JSP file.
Ii. Summary of processing data (processing form data and URL parameters)
1. In general, we use GetParameter (parameter name): Gets the value of a name attribute in the corresponding form (URL). When multiple property values are the same, only the first property value can be obtained.
2, getparametervalues (parameter name): Gets the Name property value of all form or URL, returns an array. This method is available when the name of multiple property values is the same. This method can be used to work with multi-marquee and check-box data.
3. Getparametername: Gets the name of the parameter, returns the corresponding enumeration, and iterates through the enumeration like an iterator to get the corresponding character type for each parameter name.
Third, get (get the word may not be correct) JSP data in JavaScript
1, JavaScript (here refers to the client's JS script, hereinafter referred to as the script), Jsp,java three relations:
First of all, the order of the three:jsp--> into the Java Code-->web container will be changed to HTML code-----------a time to trigger, run the script.
Obviously, the JS script is executed after the JSP code (Java) code executes (and the script executes in the browser execution, the Jsp,java code executes in the Web server's Web container), so, theoretically, the parameters of the JSP cannot be passed to the script. Because the two places of execution are different.
So, to achieve a similar effect, only in the JSP to write the JS script code. Of course, the more recommended way is to put the parameters in a hidden form area, and then through the JS Dom method to get the corresponding parameter values.
2, usually, the previous way to determine whether the form is a stupid method is: getparameter (form parameter name), the result is null, indicating that there is no corresponding form submission. Now, instead of: Getmethod.equals ("post" or "get"), returns a Boolean value that determines whether the form is submitted.
The above is a review of the induction content, if there is inappropriate place, welcome to correct.
JSP servlet Basic Review Part1