How to add a declaration on JSP code ?

CK CK 3788 
Created at
Updated at  
1,128 0 0

If you have developed C or C++ program, you may know below examples.

 

// printf( "a.out");

/*
  printf( "b.out");
*/



Above code have no bug, but no code will be compiled, because it's all declarations.

In JSP, you can make declarations as well. In some documents, a declarations is also called as remark.

To add a declaration, you must use the <%! and %> sequences to enclose your declarations, as shown below. 
 

<%@ page import="java.util.*" %>
<HTML>
<BODY>
<%!
    Date theDate = new Date();
    Date getDate()
    {
        System.out.println( "In getDate() method" );
        return theDate;
    }
%>
Hello!  The time is now <%= getDate() %>
</BODY>
</HTML>


Above code is actually dead code, because it;s surrounded with <%! and %>.
 

Tags Display JSP session control session session.getAttribute Facebook X
Comments 0
Similar posts
  1. How to include file in JSP ?
    1,251
  2. How to set and get sessions on JSP code ?
    1,037
  3. How to print out text strings on HTML directly ?
    905
  4. Put Date Time on HTML
    551
  5. How to resize image ?
    1,307
  6. Send An Email Using A Bean
    1,015
  7. Word counting source program based on MapReduce framework
    692
  8. Copy text to clipboard in Javascript
    1,715
  1. Java Variant Type
    202
  2. Beyond venv: Java's Project Isolation Strategy
    478
  3. Simple Java Code to display Hello, World on the web
    564
  4. Your Comprehensive Guide to Flink & Kafka for Real-time Stream Processing
    413
  5. Why Java Spring Framework is Considered Optimized for Docker
    1,026
  6. Spring Framework: Evolution, Trends, and Architectural Innovation
    1,256
  7. Java Kafka on CentOS 7: Install, Configure, & Run with Examples
    424
  8. What Replaced JSP? Modern Java Web Dev Explained (with Examples)
    255
  9. Java Maps: HashMap vs. LinkedHashMap vs. TreeMap Explained
    227
  10. How to resize image ?
    1,307
  11. How to set and get sessions on JSP code ?
    1,037
  12. How to include file in JSP ?
    1,251
  13. How to print out text strings on HTML directly ?
    905
  14. Clipboard copy function working
    3,368
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    40
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    34
  3. How do I create animated background for Google Meet?
    20,613
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    244
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    94
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    157
  7. Array of arguments passed to script in PHP
    90
  8. Invalid Auction Storms in Ad Tech
    98
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    202
  10. The Two Clocks of Ad Server Architecture
    70
  11. Frequency Cap Architecture Overview
    514
  12. Collecting Proof-of-Play from 100,000 Screens
    146
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    287
  14. What is RedisVL?
    109
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    230
  16. TPU & GPU Cluster Management Tools
    244
  17. The Concept of Scaffolding in AI Agents
    233
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    583
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    259
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    339
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    202
  22. Machine Learning: Training vs. Ranking
    221
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    222
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    195
  25. Designing a Data Curation System Around a Vector Database
    220
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    256
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    656
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    195
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    217
  30. Understanding Data Lineage
    260