JAVA SERVER PAGE
The JSP itself is a servlet, so it has all the benefits of a servlet.
The JSP is converted to a servlet the first time the JSP is accessed.
Extends Httpjspbase
and compile it into. class.
Jsp:
Good performance
Platform Independent
Tag can be expanded
NEWS:
Jstl
Jsf
Tag syntax, is new to launch. Simple label syntax for ease of handling.
Grammers:
1.declaration
2.scriptlet
3.expression
4.comment
5.directives
6.action Action Instruction
7. Built-in objects
1.declaration
<%!
int accesscount = 0; Member variables for servlet
member functions for void M () {}//servlet
%>
2.scriptlet:
<%
int i; Note the differences declared in <!%%>: in <%%> local variables
Java code
%>
<%=++account%>
==
<%%out.println (++account);%>
4.comments
Client comments: (Can not start the role of masking statements)
<%!----%>
Server-side comments:
<%----%>
<%
//
/*
*/
%>
Be careful that the server-side code and the client's code are not callable to each other.
<script>
<%out.println ("var i = 0");%>
alert (i);
</script>
No problem.
Dynamically generating Java Scripts
JSP---"servlet------" browser
5.directives (Compilation instruction)
<% @XXXX atr1= ""%>
Page
Include
Taglib
Indicate how to communicate with the container
<% @page import= "java.util.*" | buffer= "NONE|KB size8k"
| Iserrorpage= "True|false" | errorpage= "url"
| Contenttype= ""%>
Easy reuse: Static inclusion, access to the same request, the ContentType containing the page must be the same, can not be passed
<% @include file= "url"%>
1. Pre-compilation contains
2. The same servlet
Note: The code containing the time removes unnecessary parts
6. Action command
<jsp:include page= "url" flush= "true" >
<jsp:param name= value=>
<jsp:param name= value=>
<jsp:param name= value=>
</jsp:include>
Although not an object, (two. Class) The included page can be used to include parameters that are accepted by the page, such as upload parameter, delay load
Request included in the request
Static contains the difference from dynamic inclusion.
Different execution time periods
What the container does with it: a servlet, even a servlet
Pass parameters
The parameters included in the request are: One, one is included and contains the request and has its own information.
Response.sendredirect ("");
Accessing another servlet the current processing servlet continues to run
Command browser: Re-write address
Cannot use parameter information from previous page
This servlet code continues to execute unless added at the back: return;
Slow speed
Parameters can be passed in the URL
/representative of: HTTP://127.0.1/
<jsp:forword page= "" >
The address bar does not change:
To get the contents of the previous page
This servelt will not continue to execute
Fast speed
Parameters can be passed
/Represents the http://127.0.0.1/project/
This.getservletcontext (). Getdispatcher (). Forward ();
Using JavaBean in a JSP
There must be a method of constructing without parameters
Getters and Setters
<jsp:usebean id= "class=" "scope=" ">
</jsp:usebean>
<jsp:setproperty name= "id" property= "value=" ">
<jsp:getproperty name= "id" proterty= "" >
Scope
Page Defaults
Request
Application
Sesssion
Solve garbled problem: