Hi,
I follwed the u r suggestion for appending the result of web page to another
webpage. Here I have to append the HTML content generated by ItemServlet
class to the Html generated by the PresentationServlet. I have to add the
HTML generated by the Itemservlet for 10 times and return the resultant HTML
to the browser
Could u please help me out,
This is an example I got in the Internet and I modified a little bit.
Thanks,
Sampath


import java.io.*;
import sun.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class PresentationServlet extends HttpServlet {
        private static class ItemNotFoundException extends Exception {
                ItemNotFoundException() {
                        super("Item not found");
                }
        }
        protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
                res.setContentType("text/html");
            PrintWriter out = res.getWriter();
            out.println("<HTML><HEAD><TITLE>Item </TITLE><HEAD><BODY>");
                out.println("<FORM ACTION=\"/servlet/PresentationServlet\"
ENCTYPE=\"x-www-form-encoded\" METHOD=\"POST\">");
              out.println("<input Type=\"TEXT\" name=\"item\">");
                out.println("<input type=\"submit\" name=\"enter\" value=\"GO\">");
            out.print("</BODY></HTML>");
                out.close();

        }
        protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
                String item = req.getParameter("item");
            if(item == null) {
                }
                else {
                        res.setContentType("text/html");
                PrintWriter out = res.getWriter();
                out.print("<HTML><HEAD><TITLE>Item " + item +
"</TITLE>"+"</HEAD><BODY>Item " + item + "<P>");
                        out.print("Entered in to the doPost  method<BR>");
                        for (int i = 0; i<10 ; i++)
                                
getServletContext().getRequestDispatcher("/servlet/ItemServlet?item="+item+i).forward(req,
res);//Error here
                        out.print("Leaving From  the doPost last method");
                        out.print("</BODY></HTML>");
                        out.close();
                }
        }
}

//ITEM SERVLET Class

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

public class ItemServlet {

        public void init(ServletConfig sc) throws IOException {
}
protected void doPost(HttpServletRequest req, HttpServletResponse res)throws
ServletException, IOException {
      PrintWriter out = res.getWriter();
        String item = req.getParameter("item");
        out.print("<HTML><HEAD><TITLE>ItemServlet Output");
        out.print("</TITLE></HEAD><BODY>");
        out.print("Item Name is: " + item+"<BR>");
        out.print("</body></HTML>");
        out.flush();
      return;
}


public String getServletInfo() {
        return "File upload servlet -- used to receive files";
}

}

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

___________________________________________________________________________
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