I have tried to get it working with the EA2 of the reference impl but it
barfs badly! The EA2 doesn't follow the spec in any way shape or form so
I have tried to modify my code to fake it, but the EA2 just isn't
interested...

My Java code is...
package homelyfish.homelyfishjsp;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.io.*;
import java.lang.ClassLoader;

abstract public class HomelyFishHttpSuper implements HttpJspPage
{
  private ServletConfig config;
  protected PageContext pageContext;

  private String pageContextString = null;
  private boolean pcBoolean1 = false;
  private boolean pcBoolean2 = false;
  private int bufferSize = 0;

  // fake a super for the jsp generated, I am not supposed to have to
  // do this!!!
  public HomelyFishHttpSuper( String a, boolean b, int bufferSize,
boolean c)
  {
    // who knows what these params are???
    pageContextString = a;
    pcBoolean1 = b;
    pcBoolean2 = c;
    this.bufferSize = bufferSize;
  }

  final public void init(ServletConfig config) throws ServletException
  {
    this.config = config;

    jspInit();
  }

  final public ServletConfig getServletConfig()
  {
    return config;
  }

  // This one is not final so it can be overridden by a more precise
method
  public String getServletInfo()
  {
    return "Force the user to log in super class";
  }

  final public void destroy() // throws ServletException
  {
    jspDestroy();
  }

    // overrideable, but I shouldn't have to do this!
  public void jspInit() {}

  public void jspDestroy() {}

  final public void service(ServletRequest req, ServletResponse res)
    throws ServletException, IOException
  {
    // casting exceptions will be raised if an internal error.
    HttpServletRequest request = (HttpServletRequest) req;
    HttpServletResponse response = (HttpServletResponse) res;

    // now check to see if they have logged in.

    HttpSession session = request.getSession( true );

    boolean failed = false;

    synchronized (session)
    {
      homelyfish.homelyfishclient.HomelyFishLoginBean
         loginBean = (homelyfish.homelyfishclient.HomelyFishLoginBean)
          session.getValue( "login" );

      if ( loginBean == null )
      {
        failed = true;
        try
        {
          loginBean = (homelyfish.homelyfishclient.HomelyFishLoginBean)
              new homelyfish.homelyfishclient.HomelyFishLoginBean();
        }
        catch (Exception exc)
        {
          throw new ServletException( "Cannot create bean of class
HomelyFishLoginBean" );
        }

        session.putValue( "login", loginBean );
      }
      else
        failed = !loginBean.isLoggedIn();
    }

    if ( failed )
      config.getServletContext().getRequestDispatcher(
        "/login.jsp").forward(req, res);
    else
    {
      // shouldn't have to provide these!
      JspFactory _jspFactory = JspFactory.getDefaultFactory();

      pageContext = _jspFactory.getPageContext(
          this, request, response, pageContextString, pcBoolean1,
bufferSize, pcBoolean2 );

      _jspService(request, response);
    }

/**
* abstract method to be provided by the JSP processor in the subclass
* Must be defined in subclass.
*/
  }

  // I have to provide this?!?!?!
  protected ClassLoader getClassLoader()
  {
    return ClassLoader.getSystemClassLoader();
  }

  abstract public void _jspService(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException;
}

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to