Monday, 2004-9-27 Monday
JSP introduction
1. Overview: 1) Based on the text can return dynamic content to the client; 2) HTTP is the default protocol for request and response; 3) A page can be mixed with HTML code, Java code, and JSP tidaration; Component;
2. Good Answers in JSP: 1) Use support component model and software reuse by components; 2) Source file changes automatic compilation; In terms; 5) platform-independent; 6) Performance and scalable; 7) Reliability; as part of J2EE (servlet, JSP, and EJB are three components of J2EE).
Create, configure, and execute JSP
1. JSP Answer: 1) Development Environment A. Browser: IE / Netscape B. Development Tools: Notepad, Sunone Studio, JBuilder, WSAD 2) Configuration and Execute Environment A. Tomcat B. Weblogic C. WebSphere D. Sunone Application Server
2. First JSP page answer: 1) Script Padt: Corresponds to the service method <% ...%> or
String! " jsp: Declaration> 4) Expression (Expressions) <% = Str%> or
2004-9-28 Tuesday
1. In the JSP page, you can use the following scripting elements to insert Java code Answer: 1) declarations: <%!%> Or
2. Declarations: 1) Allow definitions to be inserted into the main body of the servlet class (by the service call, with the service () method level) method or domain; 2) Syntax: <%! Java code%> Or
Can't use); c. The scope of the declared variable or method is the current page or contains the page; D. Statement is separated by a semicolon.
3. Scriptlet Answer: 1) Java code snippet, can perform functionality than mark language 2) Syntax: <% ...%> or
4. Expression Answer: 1) Used to insert the value directly into the output 2) Syntax: <% =%> or
5. Directive Answer: 1) Page: Define the global attribute syntax of the page: <% @ Page ...%> or
6. Operations Answer: 1) Forward Action: Point the request to a specific page (similar to the requestDispatcher in the servlet); syntax:
, Scripts and expressions have not been executed; 2) Request processing Phase: A client requests a client request to the JSP page. A request object creation, resolution, and submit to compile
The corresponding servlet corresponding to JSP. When this servlet is requests, it performs the processing script applet and expressions previously defined in JSP.
9. Use the shortcomings and guidelines for script code: 1) Disadvantages: a. Excessive scripting code uses JSP page confusion and difficult to maintain; b. Scripting code reduces JSP two main advantages: software reuse and code separation 2) Guide Policy: Use only when component functions are in powerless or need limited scripts.
Wednesday, 2004-9-29 Wednesday
1. JavaBeans A: 1) JavaBeans is a lightweight, platform-independent, a component model written with Java to create reusable components; 2) Beans can be generated to create a robust, cross-platform application and applet .
2. JSP and components Answer: 1) When needed, JSP can access JavaBean and EJB; 2) JSP uses the Action tag to use, modify, and create server-side objects (such as beans);
3. JavaBean Answer: 1) Bean class must have a constructor without parameters; 2) The bean class should have no public instance variable (domain); 3) consistent values should be obtained by GET and SET methods .
4. Basic use of bean: 1) Call bean syntax:
Simple type conversion d. Create all attributes and input parameters:
5. Share Bean Answer: 1) Scope Scope: A. Variables will also be located in the servletContext object; c. Session: Indicates that the bean object is binding to a local variable, and will be located in the HTTPSession object located in the current request; D. Request: Indicates the bean object, in addition to being bound to local variables, It will also be in the servletRequest object; 2) Ways to call beans:
Abnormal processing
1. Runtime Answer: 1) An error in a program running; 2) Can be used in an inherent exception object reference; 3) You can create or generate a JSP page to display exception information to the user using an exception reference.
2. Create an exception tracking scheme: 1) In each JSP page, contain the exception page name to be created; <% @ page import = "Numberguess.NumberguessBean" ErrorPage = "error.jsp"%> 2) Create an exception Page; <% @ page isrrorpage = "true"%>
3. Answer: 1) <% = exception.toString ()%> Print anomalies; 2) <% exception.printStackTrace ();%> Print all errors in the current error stream; 3) <% = exception.getMessage ()%> Detailed description information of printing errors
Advanced theme
1. JSP in Summerside recognize the intrinsic objects A: Name Type Comment and scope of the request javax.servlet.http.HttpServletRequest request response javax.servlet.http.HttpServletResponse response pageContext javax.servlet.jsp.PageContext page session javax.servlet.http. HttpSession session application javax.servlet.ServletContext ServletContext out javax.servlet.jsp.JspWriter output stream config javax.servlet.ServletConfig ServletConfig page javax.lang.Object page Exception java.lang.Throwable page
2. Request A: Request) A: Method: 1) getCookies: Get a cookie array; 2) getMethod: Return to the request formation (Get / post); 3) getParameterNames: return to Form Object name enumeration; 4) getParameter: Returns the object value of the specified name; 5) getParameterValues: Returns the object value array of the specified name; 6) SetAttribute: Setting the property; 7) GetAttribute: Return to the property value; getAttributeNames: Return the property name Enumeration 3. The default object OUT Answer: An instance of JSpWriter, used to send response to client methods: 1) Print / println (string) 2) Print (int) / println (int) 3) Flush ( )
4. EXCEPTION Answer by default: 1) Exception instance for exceeding an abnormality object;
5. Default Objects Answer: 1) An instance of httpsession for keeping state in a session 2) method: getAttribute () setttribute () Removeattribute () getAttributeNames ()
6. Application Answer for Default Objects: 1) ServletContext An instance for keeping Application Status 2) Method: GetAttribute () setttribute () getinitParameter () getServletInfo () 3) Application's scope is much larger than session, one session Contact with a client, and Application has maintained for all guests
Noodle status