Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Scriptlets

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

If scriplets are discouraged in JSP's, then how we can override _jspInit() method and _jspDestroy() method without scriptlets.

 
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well I think first you need to look at this ...
 
gurneeraj singh
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my mistake, how can we override jspInit() and jspDestroy() method without using scriptlets.
 
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ankit, very usefull link,

Thanks
 
Ankit Garg
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well if you are overridding the jspInit or jspDestroy methods, then that means that you'll have some business logic in your JSP. But this is the whole concept of having scriptless JSPs. You try to separate business logic from presentation tier. So you are not supposed to override the jspInit or jspDestroy methods. I don't think there is any use of overridding them except using some business logic...
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

how can we override jspInit() and jspDestroy() method without using scriptlets.


I agree with Ankit. Why would you override them ? That's the whole point. Don't use scriptlets, don't do java stuff in jsp, like overriding life cycle methods.
 
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been working with JSP for 10 years (since version 0.92) and I have never had a need to override these methods.
 
Milton Ochoa
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can override this methods using

<jsp:scriptlet> public void jspInit(){ //do something } </jsp:scriptlet>
 
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

gurneeraj singh wrote:
If scriplets are discouraged in JSP's, then how we can override _jspInit() method and _jspDestroy() method without scriptlets.



Yes, scriptlets are discouraged in JSPs. And yes, you need scriptlets to override those methods. But there's no contradiction there. What is your question?
 
Ranch Hand
Posts: 47
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Milton Ochoa wrote:you can override this methods using

<jsp:scriptlet> public void jspInit(){ //do something } </jsp:scriptlet>



I think you should use declaration for this as jspInit() is a method.this will not work.


should work
 
Ankit Garg
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice catch Kosala, I suppose no one noticed it earlier :-)
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic