Please help!

I'm using jswdk-1.0-ea on Linux 2.2 with blackdown.org's JDK 1.2,
pre-release-v1.  I'm trying to implement the model 2 approach.  It
sounds simple, I even had it working under .92 but no matter what I
do, I can't get it to work under 1.0ea.

I've read many posts from the mailing list archives including the
excellent post from Craig McClanahan
http://archives.java.sun.com/cgi-bin/wa?A2=ind9907&L=jsp-interest&F=&S=&P=7211
and the JSP FAQ.  Please take a look and let me know where I'm making
the (obvious?) mistake.  Any hints will be greatly appreciated.

foo is the servlet.  foo instantiates the bean blah.bar, sets a data
member of the bean (userFullName) to a string, saves the bean in the
session and performs a sendRedirect to the jsp (foo.jsp).  The jsp
simply calls a method in the bean to display the value that was saved
by the servlet.  One thing that worries me is that a NEW instance of
the bean is created by the jsp (I know this because I have put a debug
message in the constructor).

The messages returned by the servlet runner are at the bottom.


=============================================================================
FILE: /usr/local/java/jswdk-1.0-ea/examples/jsp/blah/foo.jsp
-----------------------------------------------------------------------------
<%@ page language="java" import="blah.*" %>

<jsp:useBean id="the_state" scope="session" class="blah.bar" />

<%= the_state.getUserFullName() %>



=============================================================================
FILE: /usr/local/java/jswdk-1.0-ea/examples/WEB-INF/servlets/foo.java:
-----------------------------------------------------------------------------
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import blah.*;

public class foo extends HttpServlet
{
  private String JSPSCRIPTDIRECTORY = "/examples/jsp/blah"; // KLUDGE

  public void init(ServletConfig config) throws ServletException
  {
    super.init(config);
  }

  public void doPost (HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
  {
    // Get the session object.  Create one if it doesn't exist
    HttpSession session = req.getSession(true);

    bar state = new bar();
    state.setUserFullName("THIS IS A STRING");
    session.putValue("the_state", state);
    res.sendRedirect(JSPSCRIPTDIRECTORY + "/foo.jsp");
  }

  public void doGet (HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
  {
    doPost(req, res);
  }
}

=============================================================================
FILE: /usr/local/java/jswdk-1.0-ea/examples/WEB-INF/jsp/beans/blah/bar.java
-----------------------------------------------------------------------------
package blah;

import java.io.*;

public class bar implements Serializable
{
  public String userFullName;
  public bar ()
  {
    System.out.println("*** IN  bar::bar ***");
  }

  public String getUserFullName()
  {
    return ("ABCD" + userFullName);
  }

  public void setUserFullName(String uname)
  {
    userFullName = uname;
  }
}


=============================================================================
Output:

startserver print this on the console:

Loaded configuration from file:/usr/local/java/jswdk-1.0-ea/default.cfg
endpoint created: :8080
com.sun.web.core.InvokerServlet: init
foo: init
*** IN  bar::bar ***
com.sun.jsp.runtime.JspServlet: init
Scratch dir for JSP-generated servlets is: work/%3A8080%2Fexamples
IMPORTANT: Do not modify the generated servlets
JspEngine --> /usr/local/java/jswdk-1.0-ea/examples/jsp/blah/foo.jsp
*** IN  bar::bar ***


NOTE that the bar object is being created twice:  Once in the servlet
and the second time by the jsp.  I want the jsp to use the object that
was created by the servlet.

-----------------------------------------------------------------------------
In lynx, I see:

ABCDnull

(please note the 'null')

Thank you so very much for any help...


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com

===========================================================================
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