I'm sure one of the experts on this list will correct me if I'm wrong, but I
think ServletExec's behavior is correct, and the behavior of the other two
servlet engines is non-standard.

According to the spec, JSP pages created by servlet containers are to
implement the javax.servlet.jsp.HttpJspPage interface. Neither this
interface nor its parent interfaces (javax.servlet.jsp.JspPage and
javax.servlet.Servlet) define the getServletContext() method. Therefore,
invoking getServletContext() within a JSP page is (should be) invalid.

The getServletConfig() method is defined by the javax.servlet.Servlet
interface; therefore, invoking getServletConfig() is standard behavior and
works in all three servlet containers.

An equivalent way of doing what you want instead of using
getServletConfig().getServletContext() is to use the implicit "application"
object:

        application.setAttribute("xdbf",adbf);
        application.getAttribute("xdbf");

Vince Bonfanti
New Atlanta Communications, LLC
http://www.servletexec.com

> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
> Claude HONNORE
> Sent: Wednesday, July 18, 2001 11:47 AM
> To: [EMAIL PROTECTED]
> Subject: api servlet 2.3 : getServletConfig() not necessary ??
>
>
> bonjour
>
> My JSP work well with the three servlet container :
> ( JSP 1.2 and  SERVLET 2.3 )
> resin 2.01
> tomcat 4.0b5
> ServletExec 4.0
>
> but if I code in the JSP something like that :
> getServletContext().setAttribute("xdbf",adbf);
> DBF adbf = (DBF)getServletContext().getAttribute("xdbf");
>
> It works well with tomcat and resin but not with servletexec
>
>
> if I code the same like that  ( I add getServletConfig() ) :
>
> getServletConfig().getServletContext().setAttribute("xdbf",adbf);
> DBF adbf =
> (DBF)getServletConfig().getServletContext().getAttribute("xdbf");
>
> it works well with the three !!
>
> which is the right code in the new api 2.3 of servlet ?
> getServletConfig() is not necessary in this case for Tomcat, the reference
> ?? but necessary with an other servlet container ??
>
> CH
>
> __________________________________________________________________
> _________
> To unsubscribe, send email to [EMAIL PROTECTED] and include
> in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to