JSP程序設計
⑴ jsp程序設計
直接用 javascript腳本就可以實現。
把下面一段代碼保存為 test.html 雙擊運行就可以。
如果內想調整時間,容修改setTimeout("go()",3000);
3000表示3秒...
<html>
<head>
<title>newpaeg</title>
<script language='Javascript'>
function change(){
window.location="http://www..com";
setTimeout("go()",3000);
}
</script>
</head>
<body onLoad="change()">
3秒後跳轉
</body>
</html>
⑵ jsp程序設計
用Struts 來做,就一JSP,
表單上 添加
<body>
<from action="User.do">
Username:<input typr="text" name="U_name"/><br>
Password:<input tyoe="password" name="U_pass"/><br>
<radio/>
.
.
.
// 需要什麼再添加什麼
<input type="submit" value="確定"/>
</from>
</body>
JSP頁面寫好了,添加一個form 做表單收集
public class From extends ActionForm {
private String U_name;
private String U_password;
public String getU_name() {
return U_name;
}
public void setU_name(String u_name) {
U_name = u_name;
}
public String getU_password() {
return U_password;
}
public void setU_password(String u_password) {
U_password = u_password;
}
}
寫一個Ation類,從fron得到數據,傳到DAO層,做資料庫寫入操作
⑶ 《JSP程序設計》期末考試試題A
so easy!
⑷ JSP程序設計中的"i++"什麼意思
這個 i++ 對於java程序,是指 i 這個變數 自增 1 的意思
如:
int i = 0;
執行完這行代碼 後 i++;
i 的值已經變成了1 。
i++ 意思 是,自增加 1
⑸ JSP程序設計
jsp代碼:
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
<table width="80%" border="1" align="center">
<tr>
<td height="61" colspan="2" align="center">
<jsp:include page="head.jsp"></jsp:include>
</td>
</tr>
<tr>
<td width="21%" height="208" align="center">
<jsp:include page="left.jsp"></jsp:include>
</td>
<td width="86%" align="center">
<font color="red">${list }</font>
<form action="UserServlet" method="post">
姓名:<input type="text" name="username"><br>
密碼:<input type="text" name="password"><br>
<input type="submit" value="登錄"><input type="reset" value="重置">
</form>
</td>
</tr>
<tr>
<td height="68" colspan="2" align="center">
<jsp:include page="tail.jsp"></jsp:include>
</td>
</tr>
</table>
</body>
</html>
servlet代碼:
package com.test.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.gly.bean.UserPlace;
@SuppressWarnings("serial")
public class UserServlet extends HttpServlet {
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String method = request.getParameter("method");
String username = request.getParameter("username");
String password = request.getParameter("password");
UserPlace user = new UserPlace();
if(user.Login(username, password)){
request.getRequestDispatcher("suce.jsp").forward(request, response);
}
else{
request.setAttribute("list", "抱歉!您的帳號或密碼有誤");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
}
}
else{
request.getRequestDispatcher("jsp/error.jsp").forward(request, response);
}
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doGet(request, response);
}
}
⑹ JSP程序設計
可以做的,拍視頻演示demo