What is a scriptlet in JSP and what is its syntax?

JSPJava 8Object Oriented ProgrammingProgramming

A scriptlet can contain any number of JAVA language statements, variable or method declarations, or expressions that are valid in the page scripting language.

Following is the syntax of Scriptlet −

<% code fragment %>

You can write the XML equivalent of the above syntax as follows −

   code fragment

Any text, HTML tags, or JSP elements you write must be outside the scriptlet. Following is the simple and first example for JSP −

      <title>Hello World</title>
      Hello World!<br/>
         out.println("Your IP address is " + request.getRemoteAddr());
Published on 20-Mar-2019 10:24:27