aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Scriptlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Scriptlets" Watch "Scriptlets" New topic
Author

Scriptlets

gurneeraj singh
Ranch Hand

Joined: Mar 19, 2008
Posts: 80

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


SCJP 5.0 93%<br /> <br />SCWCD 5.0 97 %
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

well I think first you need to look at this ...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
gurneeraj singh
Ranch Hand

Joined: Mar 19, 2008
Posts: 80
my mistake, how can we override jspInit() and jspDestroy() method without using scriptlets.
Milton Ochoa
Ranch Hand

Joined: Oct 23, 2007
Posts: 336

Ankit, very usefull link,

Thanks
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

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...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

I have been working with JSP for 10 years (since version 0.92) and I have never had a need to override these methods.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Milton Ochoa
Ranch Hand

Joined: Oct 23, 2007
Posts: 336

you can override this methods using

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

Joined: Oct 14, 2005
Posts: 18541
    
    8

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?
Kosala W.Abayagunawardene
Ranch Hand

Joined: Dec 15, 2007
Posts: 47

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


[SCJP] ::[SCWCD]::[BCS::BIT::SCBCD] - Studying[My Blog]
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Nice catch Kosala, I suppose no one noticed it earlier :-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Scriptlets