Gumdrop

Gumdrop JSP Examples

Welcome to the Gumdrop JSP Examples! This collection demonstrates the comprehensive JSP 2.0+ support implemented in Gumdrop's servlet container, including advanced features like JSP property groups, taglib processing, and automatic includes.

🚀 JSP Features Demonstrated

JSP Example Gallery

1. Basic JSP Example ✅ Fully Working

Demonstrates: Core JSP syntax elements including page directives, imports, declarations, scriptlets, and expressions.

Features shown:

What you'll learn: How Gumdrop parses JSP syntax, generates servlet code, compiles it dynamically, and executes the resulting servlet to handle requests.

1b. XML JSP Example (JSPX Format) ✅ Fully Working

Demonstrates: Same functionality as the basic JSP but using XML-compliant JSP syntax (JSPX format) to showcase Gumdrop's dual parser architecture.

Features shown:

What you'll learn: How Gumdrop's JSPParserFactory automatically detects JSP format and uses either TraditionalJSPParser or XMLJSPParser, both generating identical servlet code from different syntax formats.

2. Scripting Restrictions Demo 🚫 Intentionally Blocked

Demonstrates: JSP property group enforcement with scripting-invalid configuration that prevents Java code execution.

Features shown:

What you'll learn: How Gumdrop's JSP implementation enforces configuration-based restrictions during parsing, providing administrators control over script usage for security and architectural compliance.

Expected Result: JSPParseException: Scripting is disabled for this JSP page

3. Custom Taglib Support 📚 Framework Demo

Demonstrates: Taglib directive processing, TLD resolution, and custom tag recognition (requires JSTL JARs for full functionality).

Features shown:

What you'll learn: How Gumdrop's TaglibRegistry resolves taglib URIs, parses TLD files, and generates appropriate Java code for custom tag instantiation and lifecycle management.

Note: Full JSTL functionality requires adding JSTL JAR files to WEB-INF/lib.

4. Prelude & Coda Processing ✅ Fully Working

Demonstrates: Automatic content inclusion via JSP property groups with prelude and coda configuration.

Features shown:

What you'll learn: How Gumdrop's JSPPropertyGroupResolver handles multiple property groups, applies preludes and codas cumulatively, and integrates them seamlessly into the generated servlet code.

JSP Property Groups Configuration

These examples are configured in web.xml with JSP property groups that demonstrate different aspects of JSP configuration:

<jsp-config>
  <!-- Basic JSP files - no restrictions -->
  <jsp-property-group>
    <url-pattern>/jsp/*.jsp</url-pattern>
    <page-encoding>UTF-8</page-encoding>
    <scripting-invalid>false</scripting-invalid>
  </jsp-property-group>

  <!-- Restricted area - scripting disabled -->
  <jsp-property-group>
    <url-pattern>/jsp/restricted/*</url-pattern>
    <scripting-invalid>true</scripting-invalid>
  </jsp-property-group>

  <!-- Enhanced area - with preludes and codas -->
  <jsp-property-group>
    <url-pattern>/jsp/enhanced/*</url-pattern>
    <include-prelude>/WEB-INF/includes/header-prelude.jsp</include-prelude>
    <include-coda>/WEB-INF/includes/footer-coda.jsp</include-coda>
  </jsp-property-group>
</jsp-config>

🏗️ Gumdrop JSP Architecture

Gumdrop's JSP implementation provides a complete JSP 2.0+ processing pipeline:

  1. JSPPropertyGroupResolver: Matches URLs to configuration and merges properties
  2. JSPParserFactory: Auto-detects JSP format and selects appropriate parser
  3. Dual Parser Architecture: TraditionalJSPParser and XMLJSPParser with automatic format detection
  4. AST Generation: Creates in-memory representation of JSP structure
  5. TaglibRegistry: Resolves taglib URIs and processes TLD files
  6. Code Generation: Transforms JSP AST into Java servlet source
  7. Dynamic Compilation: Uses internal Java compiler for runtime compilation
  8. Class Loading: Loads and instantiates compiled servlets

Getting Started

To explore these examples:

  1. Start with the Basic JSP Example to see fundamental JSP processing
  2. Compare with the XML JSP Example to see the same functionality in JSPX format
  3. Try the Prelude & Coda Example to see advanced configuration
  4. Examine the Blocked Scripting Demo to understand security controls
  5. Review the Taglib Support to see custom tag processing

Source Code

The complete JSP implementation source code is available in the src/org/bluezoo/gumdrop/servlet/jsp/ directory, including:


← Back to Main Page | Manager Application

Gumdrop JSP Engine - Full JSP 2.0+ Support