Win a copy of Kotlin for Android App Development this week in the Kotlin 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
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 67226
170
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: 67226
170
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.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!