I want to include another servlet, however, all the application variables
defined in current servlet
can not been seen the included servlet. here are some of the code. The line
'out.println((String)ob);' only
printed out 'null'. It seemed the application variable 'istatus' has not
been passed to second servlet.
Any idea? please help.

leo


servlet #1:

public class start extends HttpServlet
{
    public void doGet(HttpServletRequest request,HttpServletResponse
response) throws IOException, ServletException
    {

        ServletContext s = getServletContext();
        s.setAttribute("istatus","true");
        s.setAttribute("DOCPATH","c:\\attachment\\");
        RequestDispatcher d = s.getRequestDispatcher ("index");
        d.include(request,response);

    }

    public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
   {
      doGet(request, response);
   }
}

servlet 2:
##################

public class index extends HttpServlet
{
   public void doGet(HttpServletRequest request,HttpServletResponse
response) throws IOException, ServletException
   {
       response.setContentType("text/html");
       PrintWriter out = response.getWriter();

      Object ob = getServletContext().getAttribute("istatus");

     out.println((String)ob);    //?????????????????

     out.close();  //close printwriter
   }

  public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
  {
    doGet(request, response);
  }
}

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to