I wrote a general flow about the development environment for creating Servlet applications.
OS macOS High Sierra
Eclipse ver.4.8(Photon) I developed it using ver.4.8, but I think it's okay if you use the latest version. https://www.eclipse.org/photon/
Tomcat A container for executing Servlet https://tomcat.apache.org/download-90.cgi
Java I used JDK ver.10, but it seems that it can no longer be downloaded. https://www.oracle.com/technetwork/java/javase/downloads/index.html I wonder if you can use the latest version.
** However, with the Java version installed on the server when uploading to the server Please note that it may not work unless the Java version is matched when developing locally !! (The class file version differs depending on the Java version, and it does not work properly) **
MySQL Necessary if you want to make an application that uses a database If you press [NEXT] with the default settings, you can install normally. https://dev.mysql.com/downloads/mysql/
The location of the workspace is OK as it is unless you are particular about it
Enable tomcat server from eclipse
Select [File]-> [New]-> [Other]
Select Server, then select Next
Select the version of Tomcat server from [Apache](this time select the latest Tomcat v9.0) Leave the other items as Default and select [Done]
When complete, the Servers item will be added to the Package Explorer location. The server of the selected version of tomcat is running
Select [File]-> [New]-> [Project]
Select ** Dynamic Web Project ** in the Web and select Next
Enter the project name to be created in the project name input field Change the target runtime version to [Tomcat9 (Java10)] that was set earlier Changed the configuration item to [Tomcat9 (Java10) default configuration]
When the project creation is completed, the [Project Name] item is created in the location of Package Explorer.
Create an html file to display something for the time being Right-click on the project name and select New-> Other Select [html file] and create it under [project name / WebContent](example: index.html)
Changed index.html to feel like ↓
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TITLE!!!</title>
</head>
<body>
Qiita
</body>
</html>
This completes the project creation once
At this point, the window related to [Server] does not exist on the screen of Eclipse, so I will add a window. Select [Window]-> [View View]-> [Other] at the top of the screen.
Select Server, then select Open
Then, the [Server] window will be added to the top page of Eclipse. Right-click on the server and select Add / Remove
Here, select the project you created earlier, select [Add], and when you can move to the [Configured] field, select [Finish]. This will register the project on the server and allow it to be launched on the server.
Select the server to start from the server window and select Start Server
After confirming that the server is running, launch a suitable browser such as Google Chrome and enter the following URL http://localhost:8080/Qiita/index.html
Then, if the following screen is displayed, it is successful
The flow of this communication ** For localhost (on my PC) port 8080 (port used by tomcat) Make a request with Http and the value of index.html included in the Qiita project is returned Display the value on the browser. ** ** It has become a flow such as.
I set up a development environment on my PC, set up an Apache Tomcat server, and wrote a general flow of accessing from a browser. If possible so far, I think that all I have to do is write the source code.
Recommended Posts