<html>
<head>
<title>ThaiCreate.Com JSP Tutorial</title>
</head>
<body>
<%
java.util.Date date = new java.util.Date();
out.print("ThaiCreate.Com");
String name = "Weerachai Nukitram";
%>
Hello! <%=name%>
<br> The time is now <%= date %>
</body>
</html>
Output
Example 3
index.jsp
<html>
<head>
<title>ThaiCreate.Com JSP Tutorial</title>
</head>
<body>
<%
for(int i = 0; i < 10; i++) {
%>
Welcome to ThaiCreate.Com..line <%=i %> <br>
<%
}
%>
</body>
</html>
Output
Example 4
index.jsp
<html>
<head>
<title>ThaiCreate.Com JSP Tutorial</title>
</head>
<body>
<table border="1">
<%
for ( int i = 0; i < 10; i++ ) {
%>
<tr>
<td>Number</td>
<td><%= i+1 %></td>
</tr>
<%
}
%>
</table>
</body>
</html>
Output
Example 5
index.jsp
<%@ page import="java.util.ArrayList" %>
<html>
<head>
<title>ThaiCreate.Com JSP Tutorial</title>
</head>
<body>
<%
ArrayList<String> myArrList = new ArrayList<String>();
myArrList.add("Belgium");
myArrList.add("France");
myArrList.add("Italy");
myArrList.add("Germany");
for (int i = 0; i < myArrList.size(); i++) {
out.print(myArrList.get(i) + "<br>");
}
%>
</body>
</html>