Java web--Development Fundamentals (1)

Source: Internet
Author: User
Tags java web tomcat server

Web Development Basics

1. Deploy and start the Tomcat server.
1). Unzip the apache-tomcat-6.0.16.zip into a non-Chinese directory
2). Configure an environment variable. Java_home (point to the root of the JDK installation) or Jre_home
3). Start the server by double-clicking Startup.bat in the Apache-tomcat-6.0.16\bin directory
4). You can enter localhost:8080 in the browser to verify that the Tomcat installation is correct.
5). If a tomcat application has been started, an exception will be thrown if you start the same Tomcat application again:
Java.net.BindException:Address already in use:jvm_bind:8080
Because the port is already occupied.

2. Tomcat: Open source Servlet container.

3. You can modify the port number of the TOMCAT server by modifying the configuration information in the Server.xml file:

<connector port= "8989" protocol= "http/1.1" connectiontimeout= "20000" redirectport= "8443"/>
Change the port value to a different port number.
4. in order to enable the Tomcat server in any directory

4.1 Add D:\apache-tomcat-6.0.16\bin to Path

Once added successfully, if you start the TOMCAT server in any directory through startup, you will be prompted:

The CATALINA_HOME environment variable is not defined correctly
This environment variable are needed to run

That is, the environment variable is required to set Catalina_home

5. Set the catalina_home environment variable:
5.1 By reading the Startup.bat batch file, we know that there is a bin directory under the CATALINA_HOME environment variable.
And the bin directory has a catalina.bat file, so catalina_home point should be Tomcat
Install the root directory

The Tomcat root directory is then set to the CATALINA_HOME environment variable.

At this point, you can start and close the Tomcat server in any directory via Startup.bat, Shutdown.bat.

6. Continue reading the Startup.bat file and discover that the Catalina.bat file that started the Tomcat server

Enter Catalina directly in the Command Line window, with the following prompts:

Commands
Debug Start Catalina in a debugger
Debug-security Debug Catalina with a security manager
JPDA start start Catalina under JPDA debugger
Run Start Catalina in the current window
Run-security Start in the current window with security Manager
Start start Catalina in a separate window
Start-security Start in a separate windows with Security Manager
Stop Stop Catalina
Version what version of Tomcat is you running?

The Catalina command is like an optional parameter on.

Run: Start the server under Catalina the same command-line window.
Start: Open a new window to start the server
Stop: Shuts down the server.

7. First WEB application: development, and deployment to Tomcat server under Run

1). Create a new Java Project in Eclipse
2). Create a directory structure for WEB development under a Java project

-webcontent
-web-inf
-classes (the compiled class file must be placed in this directory.)
-lib
-web.xml (copied from the Apache-tomcat-6.0.16\webapps\docs\web-inf.
Can not be modified) HTML page JSP page picture ...
3). Create a new person class under SRC

Package com.atguigu.test;

public class Person {

Public String Getpersoninfo () {
return "person info ...";
}

}

4). Copy the class file (with the package) of the person class to the classes directory

You can automatically put the compiled class into the classes directory by modifying the default output directory:

5). Create a new JSP file in the WebContent directory:

<% @page import= "Com.atguigu.test.Person"%>
<%@ page language= "java" contenttype= "text/html; Charset=iso-8859-1 "
pageencoding= "Iso-8859-1"%>

<%
person person = new person ();
System.out.print (Person.getpersoninfo ());
%>

6). Copy the WebContent directory to Tomcat's WebApps directory and rename it to: HelloWorld

7). In the address bar of the browser, type: http://localhost:8989/helloworld/hello.jsp
See the command line print information

8). Configure the Web application under any directory:
In the Conf directory, create the Catalina\localhost directory in turn, and then test in the localhost directory
This Web application builds the Test.xml file and edits the file to enter the following content

<?xml version= "1.0" encoding= "UTF-8"?>
<context
Docbase= "E:\\java\\source\\atguigu\\java-1\\firstwebapp\\webcontent"
Reloadable= "true"/>

Java web--Development Fundamentals (1)

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.