This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Understanding JSP life cycle  RSS feed

 
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 ?
 
Marshal
Posts: 67163
169
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
Marshal
Posts: 67163
169
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.
 
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.
 
A "dutch baby" is not a baby. But this tiny ad is baby sized:
Download Free Java APIs to Work with Office Files and PDF
htttp://www.e-iceblue.com/free-apis.html
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!