js| Create | The site can now use all of these JSP syntax. We will create a Web page that has an input form where the user can enter a stock symbol to get the current stock price (with a 20-minute delay). If the input is incorrect, the error prompt page is displayed.
quote.jsp
First, create the quote.jsp page with the following code and save it in the Web directory under the JSWDK installation directory. Most pages are standard HTML with JSP code. Line six is a page instruction indicating that all errors will be sent to the "errorpage.jsp" text. Line 13th to 15th is a script segment that shows the table only if you have a "symbol" parameter. The "If" code snippet ends at 32 to 34 lines. Line 17th defines the JavaBean used, and line 18th loads its symbolic attributes based on the parameters. Lines 27th through 29 show the Bean's properties. In addition to the "If" section, no other Java code is actually involved.
Next, save the following JSP source code in the "errorpage.jsp" file in the Web page directory. Tip the This is a error page is the first line that sets the page directive Iserrorpage property to True. The previous page describes the location of the error page and this page indicates that this is the wrong page. Other JSP-specific code in the JSP file is used to access the implied exception object. The page displays only its values:
<%@ page iserrorpage= "true"%>
<title>error page</title>
<body>
<!--Print Exception-->
We got ourselves an exception:
<%= Exception%>
<a href= "quote.jsp" >Restart</a>
</body>
Quotes.java
Quotes JavaBean Get stock prices through Yahoo resources. You need to save the source code Quotes.java to the Quotes.java file in the "Classes\com\jguru" directory in the JSWDK installation directory. From this step, it will be compiled by the Javac compiler in JSDK.
When you create these two JSP files and build the JavaBean source code files and compile them, you can load "quote.jsp" from the http://localhost:8080/quote.jsp. File to view the results (assuming you did not change the JSWDK settings to use a different port). This page can certainly be done more beautifully, but it has certainly achieved the intended purpose, while well demonstrating the functionality of the JSP.
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.