aspose file tools*
The moose likes JSP and the fly likes rationale for jspInit() not throwing ServletException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "rationale for jspInit() not throwing ServletException" Watch "rationale for jspInit() not throwing ServletException" New topic
Author

rationale for jspInit() not throwing ServletException

Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Is there one?

For a regular servlet, we have the following signature:
public void init(ServletConfig config) throws ServletException

For a JSP page:
public void jspInit()

There is a note in the text of jspInit method that says: invocations to the getServletConfig() method will return the desired value. So we can at least retrieve a ServletConfig object, rather than having it passed in. But why wouldn't I be able to throw an Exception and have the JSP page 'unavailable' ?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Dunno, good question.
My favorite:
Why does java.beans.PropertyChangeSupport not have a protected constructor that assumes the current object is the event source, so you could subclass it?


[Jess in Action][AskingGoodQuestions]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

My favorite:
Why don't I understand questions like this?


GenRocket - A Test Data Generation Platform
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

An uneducated guess. As we know JSPs are converted into Servlets by the container. So the jspInit is not directly implemented in the created Servlet. I would guess that the container takes what is in this method and put it into the Servlet's init method, which would be written for you throwing the ServletException.
Plus is ServletException even available in a JSP page? The name of the Exception itself kind of answers that in that it isn't called JSPException.
So that is my guess.
But good question and I would be interested in finding out the real answer.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
It looks to me like jsp_init is some sort of dummy. Here is part of the generated code for the Tomcat example numguess.jsp. It does NOT have a custom jsp_init - instead, the service method checks to see if _jspx_init has been called, and _jspx_init does throw an exception.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: rationale for jspInit() not throwing ServletException
 
Similar Threads
jspInit()
jspInit() is Tomcat specific?
Initialization for a JSP
Page scope
Questions about ServletContext and ServletConfig