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:

<!-- Hello_Scripting.jsp
   Copyright (c) 2012, HerongYang.com, All Rights Reserved.
<%= greeting() %>
<% out.println("Hello world!"); %>
<%= "-- From JSP" %>
   private String greeting() {
      return "Scripting Elements:";

2. To deploy this JSP page, just copy the file to C:\local\apache-tomcat-7.0.32\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.

Last update: 2012.

Table of Contents

 About This Book

 JSP (JavaServer Pages) Overview

 Tomcat 7 Installation on Windows Systems

JSP Scripting Elements

 What Are Scripting Elements?

 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

 Java Servlet Introduction

 JSP Implicit Objects

 Syntax of JSP Pages and JSP Documents

 JSP Application Session

 Managing Cookies in JSP Pages

 JavaBean Objects and "useBean" Action Elements

 Managing HTTP Response Header Lines

 Non-ASCII Characters Support in JSP Pages

 Performance of JSP Pages

 EL (Expression Language)

 Overview of JSTL (JSP Standard Tag Libraries)

 JSTL Core Library

 JSP Custom Tags

 JSP Java Tag Interface

 Custom Tag Attributes

 Multiple Tags Working Together

 File Upload Test Application

 Outdated Tutorials


 PDF Printing Version