How to build a Java Web project manually __web

Source: Internet
Author: User
Tags java web

Internship six months to find that they did not manually build a Java Web project; One of the most basic things about Java Web development.

, and began to build a. There's a lot of small problems in the middle.

The first is the directory structure of the entire Web project:

Project Name: Eg:mywebtest

Below the project contains subdirectories: Web-inf,page;

Here is the need to note that Web-inf need to capitalize;

Below Web-inf need to include: Classes, LIB, two directories and Web.xml files

Classes: main storage of compiled. class files

LIB: Store the jar packages you need to rely on; The simplest project needs to be Jstl.jar, Standard.jar these two packages

Web.xml: Configuration file;

Example of a configuration file:

<?xml version= "1.0" encoding= "UTF-8"?> <web-app xmlns:xsi= 
"Http://" " 
    xmlns=" Http:// "xmlns:web=" " 
    xsi:schemalocation= "Http://" 
    id= "webapp_id" version= "2.5" > 
    <servlet >
	<servlet-class> com.xc.test.handleserver</servlet-class>
	< servlet-name>handleserver</servlet-name>
	</ servlet-mapping>
Write a

Use Javac to compile Java to get. class files. Store the compiled. class file under Web-inf;

Tomcat configuration:

The first thing to do is to add tomcat to the environment variable (this internet check)

Second, configure the virtual directory:

Server.xml in the Conf directory under Tomcat

Add in Host label

<content path= "/mywebtests" docbase= "G:\Gillion\gillion-tool\tomcat-6.0.16\tomcat-6.0.16\webapps\MyWebTests"/ >
This configuration means that the path that Tomcat recognizes is docbase; the access address we entered in the browser is http://localhost:8080/MyWebTests

If you want to configure your tomcat, you need to edit the server.xml in conf to configure the listening port

If you want to set login tomcat username password you need to modify the Tomcat-uers.xml under Conf


<?xml version= ' 1.0 ' encoding= ' utf-8 '?>
  <role rolename= ' manager '/>
  <role rolename= "Tomcat"/>
  <role rolename= "admin"/> <role rolename=
  < User Username= "Tomcat" password= "Tomcat" roles= "Tomcat"/>
  <user username= "Both" password= "Tomcat" roles= " Tomcat,role1 "/>
  <user username= haha" password= "haha" roles= "Admin,manager"/> <user "username="
  Role1 "password=" Tomcat "roles=" Role1 "/>
The next thing to do is run your tomcat ...

Then enter the address in your browser: http://localhost:8080/MyWebTests

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: 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.