Summary of JSP website development 2, jsp website development 2
With the previous study, I believe that you have some knowledge of JSP. From today on, we have actually started the JSP mode. If you have the HTML Foundation, it is much easier to learn JSP. First, JSP is used as the website development language, which is similar to HTML. What is a website? A website is composed of web pages that are composed of one page, we will start from the web page to enter our JSP development world.
The suffix of the JSP webpage is. jsp. Where is the dynamic content of JSP? The JSP page can recognize the JAVA syntax. You can type the JAVA code through <%>. It must be said that HTML can also add javascript. What is the best place for JSP, JSP can interact with the background database through select, which is the essence of JSP dynamic website development. I will introduce the knowledge of JSP website development in the next few days. Let's start with today's summary. Today we will introduce the JSP project directory structure and the tag function on the JSP page.
1. directory structure:
HelloWord: The name of our project.
Src: used to store the java code we have compiled
WEB-INF: used to store our jar package files and web. xml
Lib: used to store our jar package
Web. xml: Our configuration file
Xxx. jsp: our webpage File
2. JSP page tag function:
<% @ Page language = "java" import = "java. util. * "pageEncoding =" UTF-8 "errorPage =" error.html "%> <% String path = request. getContextPath (); String basePath = request. getScheme () + ": //" + request. getServerName () + ":" + request. getServerPort () + path + "/"; %> <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<P> page subject </p>
</body>
With this piece of code, I believe that you must have combed a lot of JSP pages. Here I will simply talk about it. In the first line of the Code, there is an errorPage = "error.html ", what does it mean? Warning is a pre-prepared error prompt feedback page. You can try it.
3. Introduction to web. xml
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>
<Welcome-file-list>
<Welcom-file> index. jsp </welcome-file>
</Welcome-file-list>
This statement is used to set the first page displayed by default for our project. One project can only appear once.
4. Automatic update:
<meta http-equiv="refresh" content="3;URL=index.jsp" />
For this, I want you to know how to use the code immediately, content = "3": indicates that the page is automatically updated 3 seconds later; URL = "xxxx. jsp ": indicates the url address updated 3 seconds later.
After talking about so many technical issues, let's finally talk about the things about web development. It is very easy to create a web page. We can implement a Web page with just a few simple statements. But how can we make this web page well and make others feel high-end at a glance? I believe this is a problem that many web designers have been thinking about. In my opinion, a good web page cannot be separated from the layout of div + css, the special effect Design of javascript, and the outstanding PS technology, with this, I believe that the web pages you have developed will surely achieve a fascinating effect. I believe that these pages are frequently used when HTML is made. How can they be used in JSP? The answer is certainly yes. These things can be used perfectly in JSP, so you can first learn some static website development knowledge for future development. Finally, we recommend several good learning websites: 1. w3school; 2. MOOC; 3. Blog.
All right, today's preliminary introduction to JSP will come here first, the next jsp + mysql database connection.