Well, I think this is all IBM's fault. If I remember correctly, IBM
implemented support for version 0.91 of Java Server Pages in WebSphere AS.
The thing is that the servlet API didn't provide support for some methods
which that version of the specification requires, such as the callPage()
method. So IBM used Sun's internal classes (which you are not supposed to
use, but everyone does that). I recommend you switch to a product which
supports standard Servlet API 2.1 and JSP 1.0, such as JRun or JavaServer
Web Development Kit, or wait until WebSphere supports it. For now I think
you might be able to find it in JSDK 2.0, but I'm not sure. I recommend you
switch to a product based on the final version of the specification.

Petr

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 16, 1999 9:20 PM
To: Petr Jiricka
Cc: [EMAIL PROTECTED]
Subject: Re: Newbie : com.sun.server.http.HttpServiceResponse





Hi Petr,
     This is the piece of code that I am trying out.It is given in
Websphere 2.0 Documentation.
     It uses this class com.sun.server.HttpServiceRequest/Response.
     Can you please tell me how do I go about executing this.
     Thanks in advance,
                    - Mahesh.



import java.io.*;
import java.beans.Beans;

import javax.servlet.*;
import javax.servlet.http.*;

import DataBean;

/******************************************************************
* PopulateBeanServlet - This servlet creates an instance of a Bean
* (DataBean), sets several of its parameters, sets the Bean instance
* as an attribute in the request object, and invokes a JSP file to
* format and display the Bean data.
*******************************************************************/

public class PopulateBeanServlet extends HttpServlet
{

   public void Service(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException
  {
      DataBean dataBean;

      // Create an instance of DataBean

      try
     {
         dataBean = (DataBean)
Beans.instantiate(this.getClass().getClassLoader(), "DataBean");
      }
      catch (Exception ex)
      {
         throw new ServletException("Can't create BEAN of class DataBean: "
                                      + ex.getMessage());
      }

      // Set some Bean properties (content generation)
      dataBean.setProp1("Value1");
      dataBean.setProp2("Value2");
      dataBean.setProp3("Value3");

      // To send the Bean to a JSP file for content formatting and display
      // 1) Set the Bean as an attribute in the current request object
      ((com.sun.server.http.HttpServiceRequest)
req).setAttribute("dataBean", dataBean);

      // 2) Use callPage to invoke the JSP file and pass the current
request object
      ((com.sun.server.http.HttpServiceResponse)
res).callPage("/DisplayData.jsp", req);

   }

} /* end of class PopulateBeanServlet */

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