JSP getting started tutorial (2)

Source: Internet
Author: User

Welcome to the assumerver Pages (JSP) technology-the method for creating dynamic content web Pages.

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 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 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.

OK. Let's go!

Lesson 1: real start

Now we start to create our first JSP page. 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">
</td> </tr> </table> <br>



Helloworld. jsp

<% @ Page info = "a hello world example" %>

<Html>

<Head> <title> Hello, World </title>

<Body bgcolor = "# ffffff" background = "background.gif">

<% @ Include file = "dukebanner.html" %>

<Table>

<Tr>

<Td width = 150> </td>

<Td width = 250 align = right>
</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. Also, because it is a JSP tag, remember to put it in front of

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, if <jsp: useBean> is written as <jsp: usebean>, an error message will appear on the server. 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.

The Code has been written. How can I test 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>

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.