File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes jspInit() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jspInit() method" Watch "jspInit() method" New topic
Author

jspInit() method

Sonalee Mohapatra
Greenhorn

Joined: Sep 15, 2003
Posts: 10
normally all scriptlet code in a jsp goes into the _jspService() method of the generated servlet class for the jsp. Is there any way we can make java code go into the jspInit() method of the generated servlet instead ? we could override the jspInit() method in the jsp. is this the only way or is there some other way to do it ?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
If you will take a look at the javax.servlet.jsp package, JspPage interface JAVADOCS, you will find your answer.
Idly Vada
Ranch Hand

Joined: Sep 02, 2003
Posts: 135
Originally posted by Sonalee Mohapatra:
normally all scriptlet code in a jsp goes into the _jspService() method of the generated servlet class for the jsp. Is there any way we can make java code go into the jspInit() method of the generated servlet instead ? we could override the jspInit() method in the jsp. is this the only way or is there some other way to do it ?

The jspInit method is similar to the init method in the javax.servlet.Servlet interface, and the jspDestroy method is analogous to the destroy method of the javax.servlet.Servlet interface. You can use the jspInit method to write initialization code.
I think this is the only way.
<%!
public void jspInit() {
// write your initialization code here
}
%>
<%
// other JSP page code and content
%>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jspInit() method