This is the fifth day of my participation in the November Gwen Challenge. Check out the details: The last Gwen Challenge 2021
Four servers
Full check after Internet information service has interface binding change port (if required)
Web site (Static Page) System (dynamic site)
Netstate-ano Displays information about ports in the current system
preface
Servelet is a class that runs in Tomcat.
Create dynamic project server //eclipse in web (Javaee) view
Any class that inherits httpServlet is a servlet
Servlets must be in Tomcat to make sense (to run) and only in Tomcat Classfish WebLogic server servlet containers where websphere can run servlets
Start the Servlet container = Start Tomcat
Your servlet must be in the web-INF /classes directory with the compiled source file bytecode
IDEA to realize the running of IIS server
1. Create an empty project
2. Create a module
3. Create your own Servlet
Write your own business logic
5. Override the service method. Receive requests from the front desk
In the blank, press the keyboard shortcut ALT+INSERTCopy the code
6. Fill in your own business logic code
package com.hbwl.web01; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.annotation.*; import java.io.IOException; @WebServlet(name = "OkServlet", Value = "/OkServlet") public class OkServlet extends HttpServlet {//ALT+INSERT // change protected to public public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {// Add your own business code system.out.println (" I am OkServlet"); }}Copy the code
7. Check project artifacts
See if project artifacts exist
An artifact is the resulting projectCopy the code
8. Configure the idea-Tomcat association
Select Tomcat on your local computer. If Tomcat is not available on your computer, download it from Tomcat.apache.org. Tomcat version 9 is usedCopy the code
9. Start Tomcat and test it
10. Test whether the Servlet can be accessed in the browser
View the open address of the Servlet you createdCopy the code
Enter in your browser: http://localhost:80/OkServletCopy the code
\
summary
If this article helps you, remember the triple concave ~