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