mon\lib\servlet-api.jar;d:\tomcat5.5\common\lib\jsp-api.jar;
4.編寫HelloWorld
<%
out.println("Hello World!");
%>
保存為HelloWorld.jsp
5.編譯HelloWorld
把HelloWorld.jsp放到tomcat的webapps\ROOT目錄下,啟動tomcat時服務器會自動把jsp文件翻譯成servlet文件
6.運行HelloWorld
在地址欄中輸入.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
String user="sa";
String password="sa";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement();
String sql="select * from jobs";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
<%=rs.getString(1)%>
<%=rs.getString(2)%>
<%}%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>