spInit
method is similar to init method of servlet. The jspInit() method is
invoked when the JSP page is initialized.
Syntax
public
void jspInit(){
//statements
}
today.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.util.Date" %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>Today : <%! Date today; public void jspInit(){ today = new Date(); } %> <%= today %> </h1> </body> </html>
Output
No comments:
Post a Comment