1. Trang chủ
  2. » Công Nghệ Thông Tin

Bài thực hành Lập trình Java 4 - Bài 2

4 18 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

Bài thực hành Lập trình Java 4 - Bài 2 yêu cầu người học viết một InputForm servlet để tạo một HTML form nhập để tra cứu danh bạ điện thoại, viết một SearchAccount servlet để tra cứu thông tin danh bạ. Mời các bạn cùng tham khảo để biết thêm chi tiết.

Ứng dụng danh bạ điện thoại: Viết InputForm servlet để tạo HTML form nhập để tra cứu danh bạ điện thoại Viết SearchAccount servlet để tra cứu thông tin danh bạ Bài 1: Viết servlet InputForm import javax.servlet.*; import javax.servlet.http.*; import java.io.IOException; public class InputForm extends HttpServlet { static final private String CONTENT_TYPE = "text/html"; //Initialize global variables public void init() throws ServletException { // TO DO } public void doGet (HttpServletRequest request, 10 HttpServletResponse response) 11 throws ServletException, IOException { 12 13 14 } } // TO DO //Process the HTTP Get request public void doGet ( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(CONTENT_TYPE); PrintWriter out = response.getWriter(); // Write to client out.println(“InputForm"); out.println(""); out.println("Trang Web demo viec tra danh ba dien thoai."); out.println(""); 10 out.println("Nhap ten thue bao: Nhap dia chi : Bài 2: Viết servlet SearchAccount import javax.servlet.*; import javax.servlet.http.*; import java. io.*; import java. util.*; import java. sql.*; public class SearchAccount... out.println("" + i +"" + rs.getString (2) + 11 "" + rs.getString(3) + "" + 12 rs.getString (4) + " "); 13 } // end for 14 } // end if 15 out.println("");... String newSQL = "SELECT * FROM CUSTOMER"; 12 if (tentbao != null && tentbao.length() != 0) { 13 newSQL = newSQL + " where tentbao like '%" + tentbao + "%'"; 14 } 15 String conStr = "jdbc:odbc:DanhBaDT";

Ngày đăng: 08/05/2021, 12:26

w