JSP Scriptlet – Syntax and Example
A scriptlet can contain any number of JAVA language statements, variable or method declarations, or expressions that are valid in the page scripting language.
JSP Scriptlet Syntax
1 |
<% code fragment %> |
You can write XML equivalent of the above syntax as follows:
1 2 3 |
<jsp:scriptlet> code fragment </jsp:scriptlet> |
JSP Scriptlet Example
1 2 3 4 5 6 7 8 9 |
<html> <head><title>Hello World</title></head> <body> Hello World!<br/> <% out.println("Your IP address is " + request.getRemoteAddr()); %> </body> </html> |