[JAVA] I tried to set tomcat to run the Servlet.

http://tomcat.apache.org/ Go to the site, select the version from Download on the left, and select the one that suits you from Core. This time I chose the 32-bit / 64-bit Windows Service Installer.

Install it, click the watch-like icon at the bottom right of your computer, and check that it works. If it doesn't work, enter netstat -ano at the command prompt, check if there is a port you are wearing, and you can also check from the task manager. What you see is the local address. Don't have 8080. Access http: // localhost: 8080 /. Success if a creature that you do not know whether it is a cat or a tiger appears. Since it is called context.xml, it manages the application. Contexts include server and web. The first setting can be found in server.xml. If you open tomcat, you will find bin conf lib logs temp webappas work and so on. Open webapps. There is a docs manager ROOT. Create a new folder with any name here. http: // localhost: 8080 / It can be any name. Put your own index.html here for confirmation. Displayed safely. Create a WEB-INF folder in the same location. Create a classes folder, lib folder, xeb.xml file in it. Put the Servlet class in classes. Fill in xeb.xml so that the classes of classes will be recognized. in xeb.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE web-app>

<web-app>
   <servlet>
     <servlet-name>hello</servlet-name>
     <servlet-class>aa.MA</servlet-class>
   </servlet>
   <servlet-mapping>
       <servlet-name>hello</servlet-name>
       <url-pattern> /aaa</url-pattern>
   </servlet-mapping>
</web-app>

http://localhost:8080/任意の名前のフォルダ/aaa

This should work, but for some reason it fits. The cause was not updated even if web.xml was updated. Even if I deleted it with the original file, I had to delete it because there was a file when I looked there with an editor. A mysterious phenomenon that you have to delete it twice even though it is one file.

<servlet>
   <servlet-name>The name you give it
   </servlet-name>
   <servlet-class>If there is a class name package for that, create a folder containing it
Put the class in the folder and enter it as well Example aa.hello
      </servlet-class>
</servlet>
<servlet-mapping>
      <servlet-name>
The name you are looking for
      </servlet-name>
      <url-pattern>
Desired url example/kibou
      </url-pattern>
</servlet-mapping>

It seems that / WEB-INF / classes in the folder is ignored for some reason.

Recommended Posts

I tried to set tomcat to run the Servlet.
I tried to explain the method
I tried tomcat
I tried to summarize the methods used
I tried to implement the Iterator pattern
I tried to summarize the Stream API
[Rails] I tried to raise the Rails version from 5.0 to 5.2
[Java] I tried to connect using a connection pool with Servlet (tomcat) & MySQL & Java
I tried to summarize the state transition of docker
I tried to decorate the simple calendar a little
05. I tried to stub the source of Spring Boot
I tried to reduce the capacity of Spring Boot
I tried to implement the Euclidean algorithm in Java
I tried the Docker tutorial!
I tried the VueJS tutorial!
I tried the FizzBuzz problem
I tried to verify yum-cron
I tried to implement the like function by asynchronous communication
I tried to introduce Bootstrap 4 to the Rails 6 app [for beginners]
I want to set the conditions to be displayed in collection_check_boxes
I tried to increase the processing speed with spiritual engineering
[JDBC] I tried to access the SQLite3 database from Java.
I tried to summarize the basics of kotlin and java
I want to bring Tomcat to the server and start the application
[Swift] I tried to implement the function of the vending machine
I tried to summarize the basic grammar of Ruby briefly
I tried to build the environment little by little using docker
I tried to build the environment of WSL2 + Docker + VSCode
I tried validation to unify the way hashtags are written
I tried upgrading from CentOS 6.5 to CentOS 7 with the upgrade tool
[Java] I tried to make a rock-paper-scissors game that beginners can run on the console.
I tried to summarize iOS 14 support
I tried to interact with Java
I tried the Java framework "Quarkus"
[Rails] I tried deleting the application
The story I wanted to unzip
I tried to summarize Java learning (1)
I tried to understand nil guard
I tried to summarize Java 8 now
I tried to chew C # (polymorphism: polymorphism)
I tried to explain Active Hash
I tried to solve the problem of "multi-stage selection" with Ruby
I tried to summarize the words that I often see in docker-compose.yml
[Metal] I tried to figure out the flow until rendering using Metal
I tried to summarize what was asked at the site-java edition-
I tried to illuminate the Christmas tree in a life game
I tried to sort the data in descending order, ascending order / Rails
I tried to build the environment of PlantUML Server with Docker
[Ruby] Tonight, I tried to summarize the loop processing [times, break ...]
I tried to implement the image preview function with Rails / jQuery
Special Lecture on Multi-Scale Simulation: I tried to summarize the 5th
I tried to build an http2 development environment with Eclipse + Tomcat
I tried to translate the error message when executing Eclipse (Java)
Special Lecture on Multi-Scale Simulation: I tried to summarize the 8th
I tried to check the operation of gRPC server with grpcurl
I tried to understand how the rails method "link_to" is defined
I tried to summarize the methods of Java String and StringBuilder
[Java] I tried to make a maze by the digging method ♪
I tried to move the Java compatible FaaS form "Fn Project"
I tried to solve the paiza campaign problem "Challenge from Kaito 813"
I tried to display the calendar on the Eclipse console using Java.