Hi,

According to section 2.8 of the spec version 1.1 PR implicit objects
have different scopes, e.g. request has request scope and session has
session scope. But when I test this with jswdk-1.0 I get a different
result, all implicit objects have scope page. Any ideas?

I used the following simple JSP-page to determine the scope

<html><body>
<%@ page  import="java.util.*" session="true"%>
<H1 align="center">Implicit Objects in JSP</H1>

<% pageContext.removeAttribute("javax.servlet.jsp.jspApplication"); %>
<%!
  String table(int scope, PageContext pageContext) {
     Enumeration e = pageContext.getAttributeNamesInScope(scope);
     if (e == null || !e.hasMoreElements()) return "No Objects";
     StringBuffer result = new StringBuffer();
     result.append("<table BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">");
     result.append("<tr><th>Attribut</th><th>Class</th><th>Superclass</th>
                       <th>Interfaces</th></tr>");
     for (;e.hasMoreElements(); ) {
        String attName = (String) e.nextElement();
        Object attValue = pageContext.getAttribute(attName, scope);
        if (attValue != null) {
          Class cl = attValue.getClass();
          Class superCl = cl.getSuperclass();
          Class[] interfaces = cl.getInterfaces();
          result.append("<tr><td>" + attName + "</td><td>" + cl.getName()
                          + "</td><td>" + superCl.getName() + "</td><td>");
          if (interfaces.length == 0)
            result.append("&nbsp;");
          else {
            for (int i = 0; i < interfaces.length-1; i++)
              result.append(interfaces[i].getName() + ", ");
            result.append(interfaces[interfaces.length-1].getName());
          }
        }
        else
          result.append("<tr><td>"+attName+"</td><td>no value</td><td>&nbsp;");
        result.append("</td></tr>");
     }
     result.append("</table>");
     return result.toString();
  }
%>

<br><%--<%@ include file="counter.jsp" %><br> <%= " 5%\\>x"  %> --%>
<H2>Request Scope </H2>
<%= table(javax.servlet.jsp.PageContext.REQUEST_SCOPE, pageContext)%>

<H2>Page Scope </H2>
<%= table(javax.servlet.jsp.PageContext.PAGE_SCOPE, pageContext)%>

<H2>Session Scope </H2>
<%= table(javax.servlet.jsp.PageContext.SESSION_SCOPE, pageContext)%>

<H2>Application Scope </H2>
<%= table(javax.servlet.jsp.PageContext.APPLICATION_SCOPE, pageContext)%>
</body></html>



volker turau
FH Wiesbaden Fachbereich Informatik
Tel.: +49-611-9495-205 FAX +49-611-9495-210
http://www.informatik.fh-wiesbaden.de/~turau

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to