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