• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jspInit() method

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you will take a look at the javax.servlet.jsp package, JspPage interface JAVADOCS, you will find your answer.
 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
%>
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic