<html> <head> <title>ThaiCreate.Com JSP Tutorial</title> </head> <body> <%! int count1 = 0; %> Variable count1 = <%=++count1 %> <br><br> <% int count2 = 0; %> Variable count2 = <%=++count2 %> </body> </html>
<%!String[] country = null; %> <html> <head> <title>ThaiCreate.Com JSP Tutorial</title> </head> <body> <% if(country == null) { country = new String[] { "Belgium", "France", "Italy", "Germany", "Spain" }; out.print("Country Array new assign value."); } else { out.print("Country Array already value."); } %> </body> </html>
<%@ page import="java.sql.Connection" %> <%@ page import="java.sql.DriverManager" %> <%@ page import="java.sql.SQLException" %> <html> <head> <title>ThaiCreate.Com JSP Tutorial</title> </head> <body> <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); %> <%! Connection connect = null;%> <% if(connect!=null) { out.print("Database Already Connected"); } else { try { connect = DriverManager.getConnection("" + "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};" + "DBQ=C:\\java\\mydatabase.mdb;uid=;pwd=;"); if(connect != null){ out.print("Database New Connected"); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } connect.close(); %> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท