JSP Tutorials - Herong's Tutorial Examples - v5.11, by Herong Yang
Example JSP Page with Scripting Elements
This section provides a tutorial example JSP page, Hello_Scripting.jsp, with some scripting elements: 1 scriptlet, 2 scripting expressions and 1 scripting declaration.
To verify those JSP page conversion rules, let's write a very simple JSP page with some static data and scripting elements and deploy it on the Apache Tomcat server to see how it will be converted.
1. Write the following JSP page, Hello_Scripting.jsp:
<html><body> <!-- Hello_Scripting.jsp Copyright (c) 2002 HerongYang.com. All Rights Reserved. --> <pre> <%= greeting() %> <% out.println("Hello world!"); %> <%= "-- From JSP" %> </pre> </body></html> <%! private String greeting() { return "Scripting Elements:"; } %>
2. To deploy this JSP page, just copy the file to C:\local\tomcat\webapps\ROOT\Hello_Scripting.jsp.
3. Run a Web browser and enter this URL: http://localhost:8080/Hello_Scripting.jsp. You should see this output on the browser screen:
Scripting Elements: Hello world! -- From JSP
The above result shows that:
See the next tutorial to find out where the converted Java source code is located.
Table of Contents
JSP (JavaServer Pages) Overview
Tomcat Installation on Windows Systems
Converting JSP Pages with Scripting Elements
►Example JSP Page with Scripting Elements
Example Java Class Converted from a JSP Page
Mixing Static Data with Scriptlets for Compound Statements
Syntax of JSP Pages and JSP Documents
JavaBean Objects and "useBean" Action Elements
Managing HTTP Response Header Lines
Non-ASCII Characters Support in JSP Pages
Overview of JSTL (JSP Standard Tag Libraries)
Multiple Tags Working Together
Using Tomcat on CentOS Systems
Connecting to SQL Server from Servlet