Java Web Learning (4): Developing Web applications with bare hands

Source: Internet
Author: User
Tags java web tomcat server

directory structure of a tomcat server

Before developing a Web application, it is necessary to introduce the directory structure of the Tomcat server first.

1) We open the installation directory of the installed Tomcat server, mine is: E:\Java\develop\apache-tomcat-8.0.36, that is, we are equipped with

placed the variable value of the environment variable catalina_home.


Let's start with a holistic look at the descriptions of each directory:


2) The Windows batch stored in the Bin directory is important, including the start and stop of the Tomcat server, as well as some jar files, and Tomcat

Service running files for the service.


3) The Conf directory is a Tomcat server configuration file, it is also more important, manually modify the configuration file is also a common thing we encounter

The situation, encountered to know where to modify, where to configure.


4) The Lib directory is where we use the various jar files of the Tomcat server.


5) Logs directory is the Tomcat server log files, we on the Tomcat server every time every second of the project published, the log will be stored in memory

Recorded.


6) The WebApps directory is the file that the Web project publishes.


7) Works is a servlet that is hosted by the Tomcat server by JSP.


Two writing the first Web application manually

1) Create the project directory under the WebApps directory, the name I use is myhome.


2) Create a index.jsp file in the MyHome project directory, and right-click to open the file with notepad++, enter some HTML code,

the display.


3) Create the Web-inf directory under the MyHome project directory and create the classes and Lib files in the Web-inf directory.


4) Copy the config file of Web. XML under the examples file of the sample document , where the contents remain as follows:


4) We refer to the case project examples is the Tomcat server comes with.


5) After the creation is complete, we start the Tomcat server, test run, Address: http://localhost:8080/myhome/index.jsp


6) We will access the address index.jsp, then we use http://localhost:8080/myhome will still access to the INDEX.JSP Web site

Capacity. This is the Tomcat server defaults to index.jsp as the project's Welcome home page.


Three Web-inf catalogue detailed

we open the examples in the case catalog Web-inf Directory:


1) Web-inf is a secure directory for Java WEB applications, so-called security is a directory that the client cannot access, only the server can access.

We create a new test,html file under the Web-inf directory under the MyHome project, inside the code, our client tries to access this

text page 404 error, meaning that we cannot find the requested resource file.



2) Web. XML Project deployment file (including the project's Welcome Home page).

we changed the index.jsp file under the MyHome project to first.jsp. Then we open the project again, the input first.jsp will be displayed, no input will not

will appear welcome first page, reported 404 error.



then we You can add the Welcome home page information in the Web. XML configuration file under the Web-inf directory you created, as shown in the following code:


After the modification is complete, the Tomcat server needs to be restarted and we re-enter the project address: Http://localhost:8080/myhome will open the homepage.


3) Class folder for placing *.class files (bytecode files).


4) Lib folder for storing the required jar packages.






Java Web Learning (4): Developing Web applications with bare hands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.