Summer Vacation Study Plan: DAY_1.JSP&SERVLET&TOMCAT environment to build a basic understanding.

Source: Internet
Author: User

1. Learn about JSP and Servlet (Baidu understands it).

2. Understand b/S and C/s. are browser/server and client/server respectively. where b/s is called thin mode (mainstream mode).

3. Understand and download the Tomcat server: Web application server, lightweight. Link: Http://pan.baidu.com/s/1nvcCNVF Password: 4fzz

4. Learn about Tomcat's file directory structure:

Among them, attention should be paid to:

/bin holds the startup/shutdown Tomcat script file, the. bat suffix is under windows, and SH is under Linux.

/conf holds various global settings files for Tomcat, including Server.xml and Web. xml

/webapps Tomcat's Web publishing directory, where the Web app's storage address is by default.

/work stores the JSP compiled class document.

5. Use Tomcat to write a HelloWorld page.

A. Create a new folder under the/webapps document (same as the project name) new as: Hello.

B. Copy the Web-inf folder from examples to Hello and delete the other files except Web. Xml.

C. Copy index.html to Hello, and modify the code as follows:

1 <!DOCTYPE HTML><HTMLLang= "en"><Head>2 <MetaCharSet= "UTF-8">3 <title>Hello</title>4 </Head>5 <Body>6 <P>7 <H1>Hello World</H1>8 <P></P>9 </Body></HTML>

D. Run Tomcat, find the Startup.bat double-click in the/bin directory to run Tomcat (Shutdown.bat is off, the sh suffix file under Linux).

E. Open the browser and enter the address: Http://localhost:8080/Hello, where Hello is the new folder name.

6. Write a Hello world using eclipse:

A. Create a new dynamic Web project, named Hello.

B. Locate servers, right-new-server the new Tomcat server, locate Apache, and create a new Tomcat v7.0 server. Then associate the local Tomcat folder.

C. On the newly created server, right-click on the Add Add remove to add the project to the server.

F. In the new project found webcontent new JSP file named index.jsp, modify the source code as follows:

1 <%@ Page Language="Java"ContentType="text/html; charset=iso-8859-1"2 pageencoding="iso-8859-1"%>3 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">4 <HTML>5 <Head>6 <Metahttp-equiv= "Content-type"content= "text/html; charset=iso-8859-1">7 <title>Hello</title>8 </Head>9 <Body>Ten Hello World One </Body> A </HTML>

G. Run the Tomcat server in servers. Open Browser input address: Http://localhost:8080/Hello.

7. You can export the project to package, right-click the project name-export-war file. After the export can be decompressed, or can be placed in the Tomcat directory under the/webapps directory, run Tomcat will be self-extracting.

8.JSP basic syntax.

A. The new JSP file is as follows:

1 <%@ Page Language="Java"ContentType="text/html; charset=iso-8859-1"2 pageencoding="iso-8859-1"%>3 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">4 <HTML>5 <Head>6 <Metahttp-equiv= "Content-type"content= "text/html; charset=iso-8859-1">7 <title>Insert Title here</title>8 </Head>9 <Body>Ten  One </Body> A </HTML>
View Code

B.page directive: 1). Language: Select the scripting language to use. You can use Java.

2). ContentType: The MIME type of the response that defines the encoded page of the JSP character.

3). Pageencoding:jps The character encoding of the page, use Utf-8. Otherwise, you may not be able to use Chinese.

C.scriptlet Tags:

You can embed Java code with scriptlet tags.

1). <%! %> defines global variables, methods, and classes.

2). <%%> defines a local variable, method.

3). <%=%> Enter the value of a variable or a specific method.

9.JSP contains instructions:

1). Static contains: <%include file = "file name"%> come over and compile, there may be multiple problems such as variable name duplication.
2). Dynamic include: <jsp:include page = "file name"/> Compile it and bring it back. The main use of this method.

10.JSP Jump Instruction (Preliminary understanding):

<jsp:forward>

<jsp:param value = "" name = "" >

</jsp:forward>

Features: The page jump, and will not change the path of the URL, while the value can be transferred.

Completion time: 2017-22-07.

Summer Vacation Study Plan: DAY_1.JSP&SERVLET&TOMCAT environment to build a basic understanding.

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.