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