Mohsin Shaikh
Mohsin Shaikh

Reputation: 504

Jsp lify cycle methods why jspService() method is start with the "_" character

There are three life cycle methods of JSP

1) jspInit();
2) _jspService();
3) jspDestroy();

but here the why jspService() method is start with the "_" character.

Upvotes: 1

Views: 356

Answers (1)

fGo
fGo

Reputation: 1146

As it deviates from the standard Java naming convention, it could be a way to suggest that should never be defined by the JSP page author.

As per the other methods:

  • When a container loads a JSP it invokes the jspInit() method before servicing any requests. If you need to perform JSP-specific initialization, override the jspInit() method:

    public void jspInit(){
      ...
    }
    
  • The jspDestroy() method is the JSP equivalent of the destroy method for servlets. Override jspDestroy when you need to perform any cleanup, such as releasing database connections or closing open files. This method has the following form:

    public void jspDestroy(){
    ...
    }
    

However these methods are not required anymore as you should not use scripting anymore. Please consider better alternatives as JSF.

Upvotes: 2

Related Questions