[JAVA] Servlet learning

■ Reasons to learn ① Because I want to experience the mechanism of Request and Response ⑫ Because I want to start up the Web server

■ Learning progress <1> Start a virtual machine with Vagrant and Virtulalbox ▼ Procedure (1) Follow the section "Building a local development environment" for dot installation.

  1. Build a virtual environment with Virtualbox and Vagrant, start a virtual machine with vagrant up
  2. Log in to the virtual machine with putty (user: vagrant)
  3. Transfer the html file (test 1.html) to the virtual machine with Cyberduck, an FTP tool.
  4. Put the PHP file
  5. Launch a web server with PHP (php -S 192.168.33.10:8000)
  6. When I hit http://192.168.33.10:8000/test1.html in the browser, the html file was drawn
  7. Maybe I can do something similar with Servlet now. I'm trying to install java and tomcat on a virtual machine launched with vagrant. (2018/01/03)

▼ What I learned ・ I learned Linux commands such as yum and sudo when using PUTTY (http://itpro.nikkeibp.co.jp/article/COLUMN/20060228/230999/) -When using Import of Java library in Eclipse, there is a problem that it is not loaded. It looks like I had to go through the build path (http://starscream.hatenablog.com/entry/20170308/1488974878)

<2> Create a GET request mechanism by linking Tomcat and Eclipse ▼ Procedure (1) Start up the Tomcat server by referring to "Clearly understand". →

Some ports (8005, 8080, 8009) required by the local host Tomcat v9.0 server are already in use. The server may already be running in another process, or a system process may be using that port. To start this server, you need to stop other processes or change the port number.

Error occurs. → Execute netstat -nao and tasklist on cmd to identify the corresponding PID. Apparently Tomcat was running separately from Eclipse light oil in the first place, so I stopped it and it was OK.

(2) Create an html file under the webcontent of the project (example) and request it at http: //localhost:8080/example/hello.html. The following events occur

・ Event I get a 404 error when I request a Tomcat html file created on Eclipse.

·hypothesis -The file generated by Eclipse has been generated in a place different from the one requested by the browser.

・ Experiment ① First, manually place the file and investigate what kind of GET request should be sent to get the file response. http://localhost:8080/example/seach.html To host-manager manager ROOT examplse docs Put search.html in each of I put search.html in each layer of works> catalina and requested it, but it does not come out

→ Place search.html under webapps> examples and I ran http: //localhost:8080/examples/search.html and it worked.

(2) Where is the file created by Eclipse? C:\Users\orahs\pleiades-4.7.2-java-win-64bit_20171225\pleiades\workspace\example\WebContent It is in

In other words C:\Users\orahs\pleiades-4.7.2-java-win-64bit_20171225\pleiades\workspace\example\WebContent The file generated above, C:\Users\orahs\apache-tomcat-9.0.2-windows-x64\apache-tomcat-9.0.2\webapps If you can generate it under, you win!

・ Conclusion The project was not added to the server! !!

▼ Reference URL -Case where the process remains and you want to delete it on Eclipse  https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1312626928 ・ Netstat http://www.atmarkit.co.jp/ait/articles/0207/20/news003_2.html -Tomcat directory  http://localhost:8080/examples/servlets/servlet/HelloWorldExample

―――――――――――――――――――――――――――――――――――――――――――――― 1/29 Inquiries at https://teratail.com/questions/110007, "Starting Tomcat 9.0 via Eclipse and unable to execute Servlet" Retry to.

■ What I did -Restart Eclipse. -Place the tomcat folder under the pleiades folder. -Delete the example project from both Explorer and Eclipse. -When creating examplse, it seems that you have to check Create deployment descriptor of web.xml, so I put it

■ Things to try later ・ Try Tomcat 8.0 → I did it in 8.5, but it was also unsuccessful. -Rewrite server.xml (I'm wondering if it's under conf under tomcat or under workspase> Server, but ...). → ■ Reference URL ・ I am addicted to building a Tomcat server with Java in Eclipse NEON.  http://ts0818.hatenablog.com/entry/2017/06/25/004155 ・ Web development project in Java at Eclipse NEON (Hello World!)  http://ts0818.hatenablog.com/entry/2017/06/25/173424 And so on.

■ Maybe it will be useful ・ Http://gomyownway.hatenablog.com/entry/2012/09/21/012637 ・ Http://blog.codebook-10000.com/entry/20130606/1370526510


2/3 (Sat) For the time being, to understand the role of web.xml and server.xml   http://www.searchman.info/java_eclipse/1020.html Try to study at. I wanted to know the roles below webapps, so http://localhost:8080がなぜかうまくいかない。 So I tried to install tomcat again. It seemed that the installation could not be done well with zip (it was useless even if I hit the above URL), so I installed the installer version and it worked.

2/4 (Sun) I messed with <wb-resource in the common.component file but it didn't work. .. When I read the textbook, D's supplement explained the deployment. It seems that Eclipse is converting from "Dynamic Web project layout" to "Java EE specification layout". It seems that the common.component file determines Before → After of it. From this, it can be said that the files under WebContent can be deployed, but Servlet cannot be deployed. What's more mysterious


7/28 (Sat) ■ Event -The added Servlet file is not built (* ← this is probably), and it is not deployed (I tried placing war in tomcat / webapps, but when I open the contents, there is no class file)

■ Items to consider -It is unknown whether it is a build problem or a deployment problem. At what stage -Is it a problem with the server.xml linkage settings? I feel that the build is not working. I am wondering whether the generation of the war file belongs to the build or the deploy.

■ Do you want to see below? https://qiita.com/saba1024/items/b24ecbae87146a631e88

Recommended Posts

Servlet learning
Servlet
Ruby learning 5
Ruby learning 3
insert servlet
Learning output ~ 11/3 ~
Ruby learning 2
Maven learning
Ruby learning 6
Learning output
update servlet
Ruby learning 1
Servlet movement
Programming learning day 3
[Java] Servlet filter
Ruby Learning # 25 Comments
Ruby Learning # 13 Arrays
For JAVA learning (2018-03-16-01)
Ruby Learning # 1 Introduction
Java learning day 5
Ruby Learning # 34 Modules
Ruby Learning # 14 Hashes
Rails learning day 3
Rails learning day 4
Ruby Learning # 33 Inheritance
[Servlet] Basic method
My learning record
Rails learning day 2
Ruby Learning # 15 Methods
rails learning day 1
java learning day 2
java learning day 1