bismillihirohmanirohim
yaa nie cara penggunaan swicth case pada JSP yang sederhana silahkan pilih 1-3 pada JSP tersebuat maka akan muncul beberapa keterangan , semisal kita input nomer 1 maka yang akan keluar "pilihan pertama candi borobudur"
yaa langsung saja buat script nya simpan dengan nama :
Swicth.jsp
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form>
<table width="396" border="1" align="center">
<tr>
<td width="164">masukan pilihan anda 1-3 : </td>
<td width="216"><input type="text" name="pilihan" /><br /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="proses" /></td>
</tr>
</table>
</form>
<strong><center>
<% String strpilihan = request.getParameter("pilihan");
if (strpilihan == null)
strpilihan = "0";
int pilihan = Integer.valueOf(strpilihan).intValue();
switch (pilihan) {
case 1:
out.println("Pilahan Pertama Candi Borobudur<br>");
break;
case 2:
out.println("Pilahan Kedua Danau Toba<br>");
break;
case 3:
out.println("Pilahan Ketiga Gunung Bromo<br>");
break;
default:
out.println("Silahkan Memilih terlebih dahulu Nomer 1 - 3");
}
%>
</center></strong>
<strong><center><a href="belajar java.jsp">KEMBALI</a></center></strong>
</body>
</html>
yaa nie cara penggunaan swicth case pada JSP yang sederhana silahkan pilih 1-3 pada JSP tersebuat maka akan muncul beberapa keterangan , semisal kita input nomer 1 maka yang akan keluar "pilihan pertama candi borobudur"
yaa langsung saja buat script nya simpan dengan nama :
Swicth.jsp
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form>
<table width="396" border="1" align="center">
<tr>
<td width="164">masukan pilihan anda 1-3 : </td>
<td width="216"><input type="text" name="pilihan" /><br /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="proses" /></td>
</tr>
</table>
</form>
<strong><center>
<% String strpilihan = request.getParameter("pilihan");
if (strpilihan == null)
strpilihan = "0";
int pilihan = Integer.valueOf(strpilihan).intValue();
switch (pilihan) {
case 1:
out.println("Pilahan Pertama Candi Borobudur<br>");
break;
case 2:
out.println("Pilahan Kedua Danau Toba<br>");
break;
case 3:
out.println("Pilahan Ketiga Gunung Bromo<br>");
break;
default:
out.println("Silahkan Memilih terlebih dahulu Nomer 1 - 3");
}
%>
</center></strong>
<strong><center><a href="belajar java.jsp">KEMBALI</a></center></strong>
</body>
</html>
Sebelum itu install xampp 81.1 keatas
lalu aktivkan
buka di localhost:8080/Swicth.jsp
Semoga bemanfaat :)

Post a Comment