Introduction to JSP Tutorial (2) _jsp programming

Source: Internet
Author: User
Welcome to the JavaServer Pages (JSP) technology-the way to make dynamic content Web pages.

If you want to learn this tutorial, I think you must be a novice in this technology. You might want to be a programmer or web designer using JSP technology to develop Web applications. This tutorial contains a series of JSP techniques and some simple code writing, each of which takes a set of examples to illustrate the principle.

I suggest you take a look at the FAQ before you study this tutorial to find out if your server is configured so that he can support and run the JSP. That way you can skip the front and see what you're interested in.

OK, crap, let ' s go!.

The first lesson: the Real beginning

Now start to do our first JSP page. Figure 1-1 shows one of the simplest JSP pages, followed by two pieces of code.



[Dukebanner.html]

<table border= "0" width= "cellspacing=" 0 "cellpadding=" 0 ">

<tr>

&LT;TD height= "width=" > </td>

&LT;TD width= "> </td>"

</tr>

<tr>

&LT;TD width= > </td>

&LT;TD align= "right" width= ">"
</td></tr></table><br>



helloworld.jsp

<%@ page info= "A Hello World example"%>



<body bgcolor= "#ffffff" background= "Background.gif" >

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

<table>

<tr>

&LT;TD width=150> </td>

&LT;TD width=250 align=right>
</tr>

</table>

</body>


Page Description:

In many JSP files you have to write this description. In the helloword.jsp:

<%@ page info= "A Hello World example"%>

A fool can also see that this sentence is not very useful, just briefly explain the role of this code.

You can write this code anywhere in the JSP file, but the good habit is to write it in front of you, and because he is a JSP tag, remember to put it in front of the
Include Description:

Include is used to invoke a local other file in the main JSP file, usually some copyright information, a scripting language, and any other code you want to reuse in other files. In this case, it is called a picture in fact. Everyone understands the meaning.

Say a few words:

In the JSP is very sensitive to the wording, there can be no error. For example, the server will receive an error message if you write <jsp:useBean> as <jsp:usebean>. Some such as class name, package name, path name and other sensitive tags, and so do not write wrong. There are some JSP tags in doubt to check the JavaServer Pages grammar cards.

The code has been written, how to test it?

I write this here under the Unix method, if you use Windows, then change the path is OK

1, first build a directory:. /jswdk-1.0/examples/jsp/tutorial/helloworld

2, handcuff these documents to the past 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/helloworld.jsp>

Related Article

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.