Title: Moloy's Servlet Demo...
") out.println("
  • " + request.getParameter("cname") + " " + request.getParameter("add")); cnt = 2; } out.println("
      "); out.println(""); } catch (Exception e) { out.println("Exception caught: "); } } }
    • hi monalisa,
          ur attached code is completely wrong,  i didn't get exactly what u want to do, but what i understood accordingly i have modified ur code and i am attaching it with this rpy.
        i have tested it using IE 5.0 and i am not getting any Exception.
       
      rakesh.
      ----- Original Message -----
      Sent: Tuesday, February 15, 2000 2:02 PM
      Subject: msg from Monalisa

      1. Hello guys


      I am trying to write a simple servlet where I want to input Company Name (cname) and Address (add) . I am enclosing my code with this msg. (please dont laugh)

      Please correct my code if it is wrong

      Love All

      Monalisa


      import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; public class mservlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); String cname = ""; String add = ""; int cnt = 1; try { //Display the result set as a list out.println(""); out.println(""); while(cnt == 1) { out.println("
      Address.:
      import java.io.*;
      import java.sql.*;
      import javax.servlet.*;
      import javax.servlet.http.*;
      
      public class mservlet extends HttpServlet
      {
              public void doGet(HttpServletRequest request, HttpServletResponse res)
                                throws ServletException, IOException
              {
                      res.setContentType("text/html");
                      PrintWriter out = res.getWriter();
                                      String cname = "";
                                      //String add = "";
                              	
                                      // Two temporary strings
                                      String[] name = { "abc","xyz","tmp" };
                                      String[] add = { "add1","add2","add3" };
                              	
                                      int cnt = 1;
                      try
                      {
                              //Display the result set as a list
                           out.println("<HTML><HEAD><TITLE>Moloy's Servlet Demo...</TITLE></HEAD>");
                           out.println("<BODY>");
                           out.println("<table width=80% > " +
                                                                       "<th>Name </th><th>Address</th> " );
                                               
                                               // put all ur code in this for loop
                                               // whether ur name and adds are coming from a recordset
                                               // or as input parameters to the servlet, it doesn't affect
                                               // where i have used arrays of name and add , u just insert ur
                                               // data from the recordset 
                                               
                                               for ( int i = 0; i < 3; i++ ) { 
                                               out.println("<tr><td align=center>" + name[i] + "</td><td align=center>" + add[i] + "</td></tr>" );
                                               
                                               }
                                               out.println("</BODY></HTML>");
                      }
                      catch (Exception e)
                      {
                              //out.println("Exception caught: ");
                                              e.printStackTrace();
                      }
      
              }
      }
      

      Reply via email to