Saturday, 14 March 2015

jspDestroy(): To free resources


The jspDestroy() method is invoked when the JSP page is about to be destroyed.

<%@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();
            }
            
            public void jspDestroy(){
               today = null;
               System.out.println("JSP page destroyed");
            }
            
        %>
        <%= today %>
        </h1>        
    </body>
</html>


After running the Application, stop the server, and check the console file. You can get the message like 'Info: JSP page destroyed' in the server console file.

Prevoius                                                 Next                                                 Home

No comments:

Post a Comment