Cnet jsp basic: Create a JSP website

Source: Internet
Author: User

Now it's time to put all the JSP syntaxes together. We will create a website with input format for users to enter the stock code and get the current stock price (about 20 minutes later ). If an error occurs, the error page is displayed.

Quote. jsp
First, use this code to create quote. jsp and store it in the webpage directory of the JSWDK installation directory. Most of the content of a webpage is in standard HTML format, while JSP code is scattered everywhere. Row 3 is a webpage editor guide that instructs you to send any errors to the errorPage. jsp file. Rows from 13th to 15 are small indicator codes. Basically, the table is displayed only when the "symbol" parameter exists. This if segment contains code from lines 32nd to lines 34. The first line defines the JavaBean to be used, and the second line loads its symbolic feature from the parameter. Rows 1 to 29 indicate the properties of beans. Except for the if segment, there is no other Java code.

ErrorPage. jsp
Then, store the following JSP original code to the file errorPage under the webpage directory. jsp. this is the implication of an incorrect webpage in the first line. This line sets the isErrorPage attribute guided by the webpage compiler to true. Although the previous page shows where the error webpage is, this page indicates that it is an error webpage. Other specific JSP code in the JSP file is used to access internal exceptions. This page only displays its values:

<% @ Page isErrorPage = "true" %>

<Html>
<Head>
<Title> Error Page </title>
</Head>
<Body>

<H1> Our Error Page

<! -- Print Exception -->
We got ourselves an exception:
<% = Exception %>
<A href = "quote. jsp"> Restart </a>
</Body>
</Html>.

Quotes. java
Quotes JavaBean uses Yahoo resources to get the stock price. The original code must be stored in the quotes. java file in the classescomjguru directory under the JSWDK installation directory. From there, you can use the JSDK compiler to compile it. Once you have created two JSP files, created the original JavaBean file, and compiled it, you can use http: // localhost: 8080/quote. jsp load quote. the jsp file is used to view the result. If you have not changed the JSWDK installation, you can use different ports> This web page can be enhanced. However, the functions presented by this page are a good example of JSP functions.


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.