JSP tutorials-basic articles-simple homepage Creation

Source: Internet
Author: User

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.

 
 
  1. [dukebanner.html]   
  2.  
  3. ﹤table border=”0” width=”400” cellspacing=”0” cellpadding=”0”﹥   
  4.  
  5. ﹤tr﹥   
  6.  
  7. ﹤td height=”150” width=”150”﹥   ﹤/td﹥   
  8.  
  9. ﹤td width=”250”﹥   ﹤/td﹥   
  10.  
  11. ﹤/tr﹥   
  12.  
  13. ﹤tr﹥   
  14.  
  15. ﹤td width=”150”﹥   ﹤/td﹥   
  16.  
  17. ﹤td align=”right” width=”250”﹥   
  18. ﹤img src=”duke.waving.gif”﹥﹤/td﹥﹤/tr﹥﹤/table﹥﹤br﹥   
  19.  
  20. helloworld.jsp   
  21.  
  22. ﹤%@ page info="a hello world example" %﹥   
  23.  
  24. ﹤html﹥   
  25.  
  26. ﹤head﹥﹤title﹥Hello, World﹤/title﹥﹤/head﹥   
  27.  
  28. ﹤body bgcolor="#ffffff" background="background.gif"﹥   
  29.  
  30. ﹤%@ include file="dukebanner.html" %﹥   
  31.  
  32. ﹤table﹥   
  33.  
  34. ﹤tr﹥   
  35.  
  36. ﹤td width=150﹥   ﹤/td﹥   
  37.  
  38. ﹤td width=250 align=right﹥ ﹤h1﹥Hello, World!﹤/h1﹥ ﹤/td﹥   
  39.  
  40. ﹤/tr﹥   
  41.  
  42. ﹤/table﹥   
  43.  
  44. ﹤/body﹥   
  45.  
  46. ﹤/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

  1. A brief overview of embedded objects in JSP
  2. Functions and principles of several encodings in JSP and Servlet
  3. Analysis of JSP Design Mode
  4. What is JSP and its strong weakness?
  5. How Tomcat improves performance on JSP pages

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.