A JSP Page with a Scriplet
<html><head></head><body>
<% out.println(“Now is” + new java.util.Date()) ; %>
</body></html>
This is the complete JSP page. We just save this text in, e.g., “date.jsp”, and install it in a suitable document directory.
Don’t forget the semicolon!
- We will see shortly that a scriplet does not always have to be a self-contained Java statement, but it must yield a legal Java program when it is inserted in the generated servlet code.
- Mistakes here may lead to odd compiler messages, relating to the surrounding, automatically generated parts of the servlet code!
- Since compilation is done on the fly, such messages appear the first time you visit the page.