ENGR 220 Lecture Notes - Lecture 1: Postgresql, Mysql

39 views7 pages
School
Department
Course
Professor
Bab 7 Penanganan Form
52
Bab 7
Penanganan Form
POKOK BAHASAN:
Tag Form
Membaca Parameter dari form HTML
TUJUAN BELAJAR:
Setelah mempelajari bab ini, mahasiswa diharapkan mampu:
1. Mahasiswa mengenal Form JSP
2. Mahasiswa dapat membaca parameter dari HTML form
7.1 Form dan pembacaan parameter
Form
Form sangat penting untuk mendapatkan informasi penting dari user sebuah
website. Pada contoh berikut ini kita membuat form sederhana untuk survey
warna kesukaan user dan mengambalikan nilainya ke user.
Langkah pertama, buat entry form html . form html tersebut akan mengirimkan
ke form.jsp untuk diproses.
Membaca parameter dari HTML form.
Parameter dari HTML Form dapat dibaca melalui interaksi dengan obyek
HttpServletRequest, yaitu dengan menggunakan method getParameter(). Sebagai
contoh :
String name = request.getParameter("NAME");
String sex = request.getParameter("SEX");
String email = request.getParameter("EMAIL");
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 7 pages and 3 million more documents.

Already have an account? Log in
Bab 7 Penanganan Form
53
7.2 Percobaan
1. Membuat form HTML:
Kode : form.html
<html>
<form action="form.jsp" method="get">
<table>
<tr><td><b>Name</b>
<td><input type="text" name="name">
<tr><td><b>Favorite color</b>
<td><input type="text" name="color">
</table>
<input type="submit" value="Send">
</form>
</html> Listing Program 7.1
2. Membuat kode form JSP
Kode : form.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
Name: <%= request.getParameter("name") %> <br>
Color: <%= request.getParameter("color") %>
</body>
</html> Listing Program 7.2
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 7 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents