• Post Reply Bookmark Topic Watch Topic
  • New Topic

Understanding JSP life cycle  RSS feed

 
Gourav Bansal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am trying to understand the JSP lifecycle and what are the methods we can override in our JSP. But get into some problem.
I usung Java 7 and tomcat 6 version.

i create a simple Page


MyJsp.jsp


When I deploy this application the JSP is converted into servlet. below is the servlet.



In this servlet I am getting _jspInit() and _jspDestroy() not the jspInit and jspDestroy Method and getting error when i tried to override :(

Can someone please help me to understand ?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, putting any Java code at all into a JSP is a poor and obsolete practice that has been discredited since 2002. You should not be trying to out Java code into JSPs written since then.

And no, you cannot override internal methods.
 
Gourav Bansal
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:First of all, putting any Java code at all into a JSP is a poor and obsolete practice that has been discredited since 2002. You should not be trying to out Java code into JSPs written since then.

And no, you cannot override internal methods.


Thanks Bear for the response.

I know we should not write the code in the JSP. This is just for understanding. But I read at many places that we can't override _jspService() but we can override jspInt() and jspDestroy(). So is it false ??

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP Specification is the horse's mouth with regard to what is allowed. I'd check there.

Even back in the Ice Ages before JSTL and EL, I never liked putting methods in a JSP, or tried to extend the lifecycle methods, so I have no recollection of what was allowed or not.
 
kalai sundar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Refer http://jsp.ourownjava.com/java-server-page/life-cycle/ for more details on JSP Life Cycle.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!