File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mat Austin
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic