What is the jspInit() method?

What is the jspInit() method?

The jspInit() method of the javax.servlet.jsp. JspPage interface is similar to the init() method of servlets. This method is invoked by the container only once when a JSP page is initialized. It can be overridden by a page author to initialize resources such as database and network connections, and to allow a JSP page to read persistent configuration data.

Why shouldn’t we use the constructor, instead of init(), to initialize servlet?

Yes. However, that shouldn’t be used. With earlier versions, Java couldn’t dynamically invoke constructors with arguments, so there was no way to give the constructor a ServletConfig. Although that doesn’t apply any more, but servlet containers still call your no-arg constructor so that you don’t have access to a ServletConfig or ServletContext.
JSP Actions - Explain JSP Actions in brief.
JSP actions can be used to print a script expression, create and store a Java Bean and for many other...
Difference between custom JSP tags and beans
Custom JSP tag is a user defined tag describing the way its attributes and its body are interpreted...
Explain how to perform browser redirection from a JSP page
The response implicit objects can be used in the following manner...
Post your comment