JSP basics of Java Web Learning notes

Source: Internet
Author: User

Tomcat is a servlet container, while Weblogic is a J2EE container. The most important thing is that Tomcat cannot be used as an EJB.

JSP is the Java Server Pages. By embedding Java code in a webpage, the dynamic page interaction function is realized. In the J2EE framework, JSP is the core technology of the presentation layer.

 

A JSP page consists of various elements for dynamic interaction. The elements are divided into five categories:

Annotations, template elements (HTML or XML Code), script elements (Declaration, expression, and script), instruction elements (page commands), and page containing instructions (include ), tag commands (taglib) and Action elements (basic functions of dynamic interactive pages are implemented through a series of standard actions ).

 

Script element Declaration (the variables and Methods declared on the JSP page ):

<%!

Stringsayhello (){

Return "helloworld !"

}

%>

Expression of the script element (the return value of the output variable or method on the JSP page ):

<% = Sayhello () %>

Script element script (refers to the common Java code embedded into the JSP page ):

<%

Strings = "Hello world !";

Out. pringtln (s );

%>

 

Command element page commands:

<% @ Page contexttype = "text/html; charset = gb2312">

Command element page contains commands (generally another JSP file ):

<% @ Include file = "header. Jap">

Command element label command:

Use a custom tag at the current location

 

JavaBean of Action elements:

<JSP: usebean> <JSP: setprooperty> <JSP: getproperty> these three actions are combined to operate JavaBean. Javabean is essentially a Java class related to data operations and is used to encapsulate data operation interfaces.

 

JSP built-in objects (9 ):

Request, session, application, page: save data in different lifecycles;

Response: indicates the response object;

Config: servlet configuration. You can obtain the initialization data of the servlet configuration from the configuration file (Web. XML;

Out: directly outputs the content;

Exception: When a running exception occurs, go to the specified Error Indication page;

Pagecontext: Manages and obtains the preceding objects, and maintains data as a container.

 

Related Article

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.