Hi all,
I need to forward the rquest and response objects from servlet1 to servlet2.

Servlet1  is the calling Servlet which has this code.
-----------

/////////////////////////////////////////////////////////////////////////////////////////
RequestDispatcher dispatcher =
this.getServletContext().getRequestDispatcher("/overhaul/jservlet/CalledServlet");

if(dispatcher != null)
     dispatcher.forward(req,res);


/////////////////////////////////////////////////////////////////////////////////////////



Servlet2  is a simple called servlet which does the req.getParameter of the
first servlet Values
------------
///////////////////////////////////////////////////////////////////////////////////////////

package jservlet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class CalledServlet extends HttpServlet
{


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


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

          doPost(req,res);
     }

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


          res.setContentType("text/html");
          PrintWriter out = new PrintWriter(res.getWriter());
          StringBuffer lstrDisplayHTML = new StringBuffer();
          lstrDisplayHTML.append("<HTML>");
          lstrDisplayHTML.append("<HEAD>");
          lstrDisplayHTML.append("<TITLE>Calling Servlet </TITLE>");
          lstrDisplayHTML.append("</HEAD>");
          lstrDisplayHTML.append("<BODY>");
          lstrDisplayHTML.append("<FORM NAME=frmTest METHOD='POST' >");
          lstrDisplayHTML.append("<P> New Servlet Called");
          lstrDisplayHTML.append("</FORM>");
          lstrDisplayHTML.append("Request" + req.getParameter("txtMode") +
req.getParameter("txtfield1"));
          lstrDisplayHTML.append("</BODY>");
          lstrDisplayHTML.append("</HTML>");
          out.println(lstrDisplayHTML.toString());
          out.close();

     }

}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

These servlets in the current state work perfectly alright and do the needful.
But If I remove the "package jservlet;" line  from the second servlet code It
stops working and an application error is thrown.
Both my servlets are in jservlet folder.
Am testing these under Oracle Application Server.

Somebody please help...Why this strange behaviour? How is the Called Servlet
path is related to Package keyword?
Also note that I have not put the package statement in the first servlet and it
works perfectly alright.
How exactly does the package <packagename> work?
I have not defined a package for the rest of the servlets and hence I want to
know if its possible
without using the package keyword.


Thanks in advance,
Vikas

___________________________________________________________________________
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