aspose file tools*
The moose likes JSP and the fly likes Over-riding JspInit() butnot Servlets init() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Over-riding JspInit() butnot Servlets init() method" Watch "Over-riding JspInit() butnot Servlets init() method" New topic
Author

Over-riding JspInit() butnot Servlets init() method

Mat Austin
Greenhorn

Joined: Dec 01, 2006
Posts: 7
Hi All,

I'm a bit puzzled by what looks like a contradiction in the official Sun Certified Web Component Developer guide. It states ( and so does everywhere else I can find on the internet) that in a servlet you can over-ride the Servlet's init method. In the JSP chapter it states that you should over-ride the JspInit method for initilisation stuff. It goes further and says that most containers will prevent you from over-riding the Servlet's init method in a JSP.

My question is this... A JSP is a servlet, you are allowed to over-ride init() for a normal servlet so why not for a JSP?

This is just intellectual curiosity - I wouldn't want to do this (probably) and I'm sure this isn't important for the SCWCD exam.

Thanks in advance for any help,
Matt
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
A JSP is a servlet

That's an implementation detail that you should not rely on. The spec says that in a JSP there will be a jspInit method, but I don't think it says that there will be an init method. That's because the JSP spec doesn't mandate that JSPs are implemented by servlets. Every single JSP container in existence may do it that way, but a container is free to do it some other way, in which case there wouldn't be an init method to override.


Ping & DNS - my free Android networking tools app
 
 
subject: Over-riding JspInit() butnot Servlets init() method