Due to the interest of Java, I started learning Java a year ago, I'm an anxious and painful for beginners in the eyes of old birds. Now I will share some experience in learning JSP. Since the level is limited, the mistake is inevitable, I hope that the old birds will not be enlighten, in order to work together.
It is said to introduce JSP but because of its complicated content, I will only focus on the use of JSP Tags. But before this, you will briefly introduce the basic knowledge of JSP, and all implementations are in the Win2000 environment.
Said so much, then what is JSP. JSP full name is Java Servlet Page, which is a text-based piece. It can display static content like HTML, SVG, WML, XML, can also process dynamic content like PHP, ASP, such as: Database.
Let's take a look at what JSP is long.
<% @ Page ContentType = "Text / HTML; Charset = GBK"%>
Code 1
It seems that it is not difficult. Friends who are familiar with HTML must soon find that the above code is almost exactly the same as HTM. But I think it is easy to guess what it means, nothing more than "Hello the World" is displayed. Maybe someone wants to ask, to display static content directly with HTML to be implemented. Yes, but from the above, JSP can also give a replacement for static display, which seems to imply the power of JSP (especially the TAG I will focus on). With the deepening of learning, this will change significantly.
The process and servlets of the JSP page processing request are similar (actually each JSP page will be built into a corresponding servlet). So the Lifecycle of JSP depends on different vendors to implement the servlet. However, when requesting the JSP page, there will be a corresponding servlet processing. And the server will automatically compare the JSP page with its corresponding servlet If the discovery page is updated, it will automatically compile new pages (unless the server is considered to change the server settings). This is very convenient to write and debugging.
It is said that many people have already tickle early (I am also a new Southam, I am most annoying, I won't have anything about it.). Below we come to Run just the JSP page.
If you want to make JSP can get up, you first need a server program that supports JSP. I recommend Tomcat, no friends can go to http://jakarta.apache.org download (free). Of course, JDK is also essential (you can download) with http://java.sun.com. After installation, you also need to set the environment variable - Java_Home, which is the directory you install JDK. After setting, you will restart the machine. After the% CATALINA_HOME% / BIN / Startup (under Windows). Then you can play in your IE as: http: //127.0.0.1: 8080 / If you see the Tomcat's index.html page, you have no problem with your installation (note that due to Tomcat to occupy 8080 port, When Startup, you must guarantee that the 8080 port is not occupied). Only did you still do a JSP page, you first open Tomcat installation directory, my D: / server / tomcat below it will find a directory called WebApps (I use Tomcat4.0.1 Different versions may vary, if you can refer to the documentation provided by Tomcat, create a directory under WebApps, such as: HOME, then build directory web-inf (this directory is Tomcat requirement, must be established, and Pay attention to the case), and then establish an XML file called Web.xml under web-infers, the content is:
Xml Version = "1.0" encoding = "ISO-8859-1"?>
Below is the last step. Create a directory named JSP under Home, and establish a Hello.jsp file under the JSP is Code 1. And then restart Tomcat and in IE http://127.0.0.1:8080/home/jsp/hello.jsp.bingo! You can see the victory.
It's good to say this today. It should be resting in so many things. See you later.