thanx Mr. William for your reply...
I used the request dispatcher as u said. But the request and response objects are not available in the another servlet even though the forward method is executed. Let me know where I have gone wrong or shall I add some other statements to make it work.
MainServlet.java
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException{
try{
System.out.println("In Post method"); // System.out.println to just check the execution of the program
System.out.println("condition satisfied");
RequestDispatcher rd = req.getRequestDispatcher("/anotherServlet");
if(rd==null)
System.out.println("object is null");
else
rd.forward(req, res);
System.out.println("its over now");
}catch(Exception e){
System.out.println("Exception occured at line 46"+e);
}
}
===============================================================
anotherServlet.java
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException{
System.out.println("I m in anotherServlet now");
PrintWriter pw=res.getWriter();
pw.println("it was successful");
pw.close();
}
I m using
tomcat 3.2.1 as my application server.
nitin