[Jsp] lesson 1 Introduction and introduction to Jsp network programming

Keywords: Java Eclipse JSP Tomcat Software

This article uses jdk1.8 version and eclipse to develop the code under the software environment. Beginners should install the environment first. If necessary, please check it

[Java] JDK installation and environment configuration

[Java] Eclipse installation and J2EE development environment configuration

Introduction to Web server

} Web Server is a server that builds a basic platform for information publishing, data query, data processing and many other applications in the network
} Sometimes, we often call it Web Server call Web container
} Common servers are: Tomcat , Resin , Weblogic , Websphere etc.
} Web How the server works
◦ The first step, Web Browser to a specific Web Server issue Web Page request
◦ Step two, Web Server received Web After the page request, find the requested Web Page to perform the corresponding functions
◦ The third step is to record the final result of the user request as Web Sent to the customer as a page Web browser

How Web server works

  Introduction to Tomcat

} Tomcat Is a free open source Web Server, providing access to Serlvet and JSP Support.
} Tomcat yes Apache Foundation Jakarta A core project in the project, which is composed of Apache , Sun Developed with other companies and individuals.
} With Sun Participation and support, the latest Servlet and JSP Norms can always be Tomcat It is reflected in.
} The latest version is 9.0 or higher , support Servlet3.1 , JSP2.3 .
} Tomcat Server is very suitable for learning Java Web Development technology beginners.
Official download address: http://tomcat.apache.org/


Tomcat directory structure

} 1 The. bin directory is mainly used to store tomcat commands. There are two main categories:
}   One is. sh (linux command)
}   The other is. bat (windows command)
} 2 The. conf directory is mainly used to store some configuration files of tomcat
} 3 The. lib directory is mainly used to store the jar packages that need to be loaded for tomcat operation
} 4 The. Logs directory is used to store the log files generated during the operation of tomcat. It is very important to output the logs on the console.
}  ( Emptying will not affect the operation of tomcat )
} 5 The. temp directory stores temporary files generated by tomcat during operation.
}  ( Emptying will not affect the operation of tomcat )
} 6 The. Webapps directory is used to store applications. When tomcat starts, it will load the corresponding files under the webapps directory            Use the program.
} 7 The. work directory is used to store the compiled files of tomcat at run time, such as jsp compiled files.
}  ( Clear the work directory and restart tomcat to clear the cache )

Industry introduction

  For beginners majoring in computer software, they can work in the following directions:

UI Designer

Web front end Engineer


Java Development Engineer



Build an introductory case of Jsp network programming

Open eclipse and right-click the directory on the left -- "new --" Dynamic web Project

After filling in the project name, click next


Check the box and click finish.

The catalog creates the project  

  Locate the web.xml file and open it

Edit the code and only use the index.jsp file as the home page

Select the WebContent folder and right click new jsp files

Create a new index.jsp file under the webContent root path

  Select the entire project and right click run as run on server

  The project is being deployed to the tomcat server

After deployment, copy the access address and access the server through an external browser.

Its code is as follows:

<%@ page language="java" contentType="text/html; charset=UTF-8"
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	function show() {
		//How can I jump to the page in JavaScript
<!-- eclipse Prompt shortcut keys for software:alt+/ -->
<span style="color: red">I am Chinese,</span><br>
<!-- h1-h6 Title label -->
<h1>Title I</h1>
<h2>Title II</h2>
<h3>Title III</h3>
<h4>Title IV</h4>
<h5>Title V</h5>
<h6>Title VI</h6>
<!-- p label:Paragraph label -->
<p>I'm a paragraph label</p>
<!-- a label :Hyperlinks-->
<a href="One.jsp">Click on me,You can jump to the page</a>
<!-- list:ol Ordered list,ul Unordered list -->
<ul type="circle">
	<li>Java programing language</li>
	<li>Mysql database</li>
	<li>Jsp Network programming</li>
<ol type="a" start="4">
	<li>Java programing language</li>
	<li>Mysql database</li>
	<li>Jsp Network programming</li>
<!-- table  tr td form  -->
<table border="1" style="width: 400px;
	text-align: center;">
	<caption>Student information sheet</caption>
	<td>Student number</td>
	<td>full name</td>
	<td>Zhang San</td>
<!-- form :Can allow users
 Some of the tags of your own input belong to form tags-->
<form action="">
	user name:<input type="text" placeholder="enter one user name"><br>
	cell-phone number:<input type="tel" placeholder="Please enter your mobile phone number"><br>
	password:<input type="password" pattern="Please input a password"><br>
	Gender:<input type="radio" checked="checked" name="sex">male&nbsp;
	<input type="radio" name="sex">female<br>
	hobby:<input type="checkbox" checked="checked">Basketball&nbsp;
	<input type="checkbox">sing&nbsp;
	<input type="checkbox">read a book&nbsp;
	head portrait:<input type="file">
self-introduction:<textarea rows="10" cols="20">content</textarea>
	date of birth:<select>
	<!-- Submit button -->
	<input type="submit" value="Submit">&nbsp;
	<input type="reset" value="Reset">
	<a href="One.jsp">
	<input type="button" value="Jump"></a>&nbsp;
	<input type="button" value="Jump 2" onclick="show()">


  The One.jsp code is as follows:

<%@ page language="java" contentType="text/html; charset=UTF-8"
<!DOCTYPE html>
<meta charset="UTF-8">
<title>Insert title here</title>
I'm the second page

Posted by frenchy373 on Fri, 10 Sep 2021 02:00:55 -0700