Now it's time to put all the JSP syntax together. We will create a Web site with input format for users to enter stock tickers and get the current stock price (about 20 minutes delay). If there is an error, the error page is displayed.
quote.jsp
First, create the quote.jsp with this code and store it in the web directory of the JSWDK installation directory. Most of the content in a Web page is standard HTML format, and JSP code is scattered everywhere. Line 6th is the Web Page Editor guide, which indicates that any errors are routed to the errorpage.jsp file. Lines 13th through 15 are small indicators, basically saying that the table is displayed only if the "symbol" parameter exists. This if section contains code from line 32nd to line 34. Line 17th defines the JavaBean to use, while line 18th loads its symbolic attributes from the argument. Lines 27th through 29 indicate the characteristics of the beans. There is no other Java code except for the IF section.
errorpage.jsp
Next, store the following JSP raw code in the Web page directory of the file errorpage.jsp. This is an error the hint of the page is on the first line, this row sets the page compiler to guide the Iserrorpage property to True. Although the previous page explains where the error page is, this page is saying that it is an error page. The other specific JSP code in the JSP file is the access to the internal exception object. This page only displays its value:
<%@ 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 uses Yahoo's resources to get stock prices. The original code needs to be stored in the Quotes.java file in the Classes\com\jguru directory under the JSWDK installation directory. From there, you can use the JSDK compiler to compile it. Once you have built two JSP files, built the JavaBean source and compiled it, you can http://localhost:8080/quote.jsp the quote.jsp file to see the results, assuming you haven't changed JSWDK installation, The use of different ports > this page can be enhanced, but the functionality it renders is a good demonstration of JSP functionality.