Learn J2EE notes from scratch

Source: Internet
Author: User
Tags html comment

1. Before the servlet3.5 specification, most components of Java Web applications use the web. XML file for configuration management, servlet3.0 specifications can be configured through annotation to manage Web components, so web. XML files can become more concise, which is also a major improvement in servlet3.0.

2. jsp annotation: <% -- this is a JSP annotation -- %> (JSP annotation is not displayed on the client)

JSP Declaration: <%! Declaration Part %>

HTML comment: <! -- HTML annotation --> (HTML annotation will be displayed on the client)

3. After JSP is compiled into a Servlet File, it is stored in the work \ Catalina \ localhost \ basicsyntax \ org \ apache \ JSP folder under tomcat.

4. After the Tomcat server compiles Java into a Servlet File, it has only one instance in the Web Container, so the member variables in this instance are shared. If you access and modify member variables by one person, others will get the modified value.

5. Three JSP compilation commands

Page: this command is for the current page (for example, <% @ page import = "Java. util. String" %>

Include: Specifies to include another page (for example, <% @ include file = "Top. jsp" %>)

Taglib: used to define and access custom tags (for example, <% @ taglib prefix = "S" uri = "/Struts-tags" %>

6. Seven action commands of JSP

JSP: forward: the execution page turns to forward request processing to the next page (for example, <JSP: Forward page = ""/>)

JSP: Param: used to pass parameters. It must be used with tags of other supported parameters.

JSP: include: Used to dynamically introduce a JSP page (dynamic loading, loading only when page requests)

JSP: Plugin: used to download JavaBean or applet to the client for execution

JSP: usebean: Create a JavaBean instance

JSP: setproperty: Set the attribute value of the JavaBean instance

JSP: getproperty: outputs the attribute value of the JavaBean attribute.

7. Nine built-in objects in JSP scripts

Application: indicates the web application to which the JSP belongs.

Config: the configuration information of JSP.

Exception: exceptions and errors on other pages

Out: the output stream of the JSP page.

Page: indicates the page itself.

Pagecontext: the context of the JSP page, which is usually used to access Shared data on the page.

Request: This object encapsulates a request, which is often used for parameter transmission.

Response: indicates the server's response to the client.

Session: indicates a session.

8. servlet Development

First, you must inherit the httpservlet class and implement the init/destroy/doget/dopost methods.

After compiling the servlet, you must configure it in Web. xml. However, after servlet3.0, you can use the annotation method to configure the servlet class without configuring it in Web. xml.

9. jsp custom tag

 

Learn J2EE notes from scratch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.