First, the basic concept of Servlet:
Servlet is a dynamic web resource development technology provided by Sun. In essence, it is a small java program. You can add a servlet to the servlet container to run.
Servlet container: The environment in which the servlet can run is called the Servlet container. — tomcat
Web container: The environment that can run web applications is called a web container - tomcat
The basic operation of Servlet:
Servlet does not have a main() method. They are controlled by another Java application (such as Tomcat), this Java application is called a Sevlet container, and Tomcat is such a container. Usually we call Tomcat a servlet container.
Servlets are executed by default in multi-threaded mode.
Note: JSP is for the convenience of writing html code and Java code, it is actually a Servlet.
Second, the configuration of MyElipse:
1. Select the workspace: As long as the workspace is switched, all configurations are cleared.
2, configure jdk:
Select the menu bar Windows–â€Preferences, select the tab Java–â€Installed JREs, the interface is as follows:
In the above picture, you can see that MyEclise has its own jdk, then we still use the jdk installed by ourselves, click the “add†button in the above figure, the following interface pops up:
In the figure above, select the jdk path you installed, then finish, continue:
3, configure the coding of the workspace: from now on, the default encoding of the text files in any project you create is utf-8
Select the menu bar Windows–preferences and select the tab General–â€Workspace as follows:
4, change the font:
Third, use MyEclipse to create a Web project:
1, MyEclipse specifies Tomcat:
Select the menu bar Window–â€Preferences, select the tab MyEclipse–â€Servers–â€Tomcat, then:
In the above picture, select your own Tomcat directory, remember to check the "Enable" in the red box.
Check the running jdk:
At the same time, we close MyEclipse to bring Tomcat:
2, MyEclipse create a Web project:
The Context root URL in the above figure refers to the virtual path of external access. Click finish to continue:
In the above picture, select "no". If you choose "yes", it will compile with 6.0 instead of 5.0. carry on:
In the image above, let you switch from the Java view to the MyEclipse view and select "yes".
The newly created project has the following directory structure:
WebTest: The name of the web project. When the project is deployed, there will be an example web application in the webapps directory.
Src directory: The development directory of the Java program. All programs written in this directory are automatically deployed to the example/web-inf/classes directory when deployed.
WebRoot directory: webroot corresponds to the root directory of the web application. All subdirectories and subfiles in the directory will be published to the web application directory when deployed.
If you need to modify the Context Root of the Web project's external access path, you can right-click on the project, select ProperTIes, and select MyEclipse–Web Label:
In the red box of the above picture, you need to change it.
3. MyEclipse publishes the web project to Tomcat:
Select the button in the above picture (below the menu bar), the prompt text is: Deploy Project to Server, the following interface pops up:
In the figure above, select add and continue:
In the picture above, choose Tomcat before us, just fine.
Of course, there is another way to publish to Tomcat by right-clicking on the project file with the following effects:
Once the project is released to Tomcat, it will immediately copy the project's WebRoot directory to Tomcat's webapps directory and rename the WebRoot to the project name, WebTest:
After publishing, if you want to see the effect on the webpage, you need to run Tomcat first:
Then enter the url at the URL:
Fourth, the general steps to create a Servlet:
The framework of the Servlet consists of:
The Servlet framework consists of two Java packages: Javax.servlet and Javax.servlet.http. The Javax.servlet.Servlet interface in the core of the Servlet framework, all Servlets must implement this interface.
step:
Fume Infinity Disposable Vape pen provides 3500 hits. Infinity is Fume`s longest lasting e-cigarette device compare to fume ultra and fume extra! Fume infinity feels like last forever before the e-juice or battery runs out! The nic salt is 5%, we can customize is to 2% or 0% according to customer require. Have a try and fume infinity will suprise you!
Fume Infinity Vape,Fume Infinity Disposable,Fume Infinity 3500,Fume Infinity 3500 Puffs
Shenzhen Kate Technology Co., Ltd. , https://www.katevape.com