Apr
30

Using Scriptlets in JSP

By admin  //  JAVA  //  View Comments

JSP also allows you to write blocks of Java code inside the JSP. This block of code is known as a “scriptlet”.   A scriptlet contains Java code that is executed every time the JSP is invoked.

<HTML>
<BODY>
<%
    // This is a scriptlet.  Notice that the "date"
    // variable we declare here is available in the
    // embedded expression later on.
    System.out.println( "Evaluating date now" );
    java.util.Date date = new java.util.Date();
%>
Hello!  The time is now <%= date %>
</BODY>
</HTML>

Related posts:

  1. Displaying current time in JSP
  2. Inheritance in JAVA
  3. What Is a Package in JAVA?
  4. ‘javac’ is not recognized as an internal or external command
  5. my first program in JAVA
blog comments powered by Disqus