Welcome to the JSP tutorial technology-how to create a dynamic content webpage.
If you want to learn this tutorial, I think you must be new to this technology. You may want to be a programmer or web designer who develops network applications using JSP technology. This JSP tutorial contains a series of JSP techniques and some simple code writing methods. Each step provides a group of examples to illustrate the principles.
I suggest you take a look at the FAQ before learning this JSP tutorial to learn how to configure your server so that it can support and run JSP. In this way, you can skip the content in the front and directly view the content you are interested in.
JSP source code:
Now let's start the first page of our JSP tutorial. Figure 1-1 shows a simple JSP page, followed by two pieces of code.
- [dukebanner.html]
-
- ﹤table border=”0” width=”400” cellspacing=”0” cellpadding=”0”﹥
-
- ﹤tr﹥
-
- ﹤td height=”150” width=”150”﹥ ﹤/td﹥
-
- ﹤td width=”250”﹥ ﹤/td﹥
-
- ﹤/tr﹥
-
- ﹤tr﹥
-
- ﹤td width=”150”﹥ ﹤/td﹥
-
- ﹤td align=”right” width=”250”﹥
- ﹤img src=”duke.waving.gif”﹥﹤/td﹥﹤/tr﹥﹤/table﹥﹤br﹥
-
- helloworld.jsp
-
- ﹤%@ page info="a hello world example" %﹥
-
- ﹤html﹥
-
- ﹤head﹥﹤title﹥Hello, World﹤/title﹥﹤/head﹥
-
- ﹤body bgcolor="#ffffff" background="background.gif"﹥
-
- ﹤%@ include file="dukebanner.html" %﹥
-
- ﹤table﹥
-
- ﹤tr﹥
-
- ﹤td width=150﹥ ﹤/td﹥
-
- ﹤td width=250 align=right﹥ ﹤h1﹥Hello, World!﹤/h1﹥ ﹤/td﹥
-
- ﹤/tr﹥
-
- ﹤/table﹥
-
- ﹤/body﹥
-
- ﹤/html﹥
Page Description:
In many JSP files, you must write such instructions. In helloword. jsp:
<% @ Page info = "a hello world example" %>
The dummies can tell that this sentence is useless, just a brief description of the role of this Code.
You can write this code anywhere in the JSP file, but the good habit is to write it at the beginning, and because it is a JSP tag, remember to put it in front.
Include description:
Include is used to call a local file in the main JSP file, usually some copyright information, script language, and other code that you want to reuse in other files. In this example, an image is called. Everyone understands this.
Just say a few words:
In JSP, It is very sensitive to writing, and there cannot be a slight error. For example Write In this way, the server will have an error message. Do not make any mistakes in some sensitive labels such as class name, package name, path name, etc. If some JSP labels are inaccurate, check the JavaServer Pages syntax card.
After the code is written, how can we test and run it?
The UNIX method I wrote here. If you use Windows, you can change the path.
1. First create a directory: ../jswdk-1.0/examples/jsp/tutorial/helloworld
2. Upload these files to background.gif, duke.waving.gif, dukebanner.html, and helloworld. jsp.
3, cd ../jswdk-1.0, and then startserver
4. Open a browser,
5. http: // yourMachineName: 8080/examples/jsp/tutorial/helloworld. jsp
- A brief overview of embedded objects in JSP
- Functions and principles of several encodings in JSP and Servlet
- Analysis of JSP Design Mode
- What is JSP and its strong weakness?
- How Tomcat improves performance on JSP pages