1. jsP簡單編程題求答案
特意花時間幫你寫了一個,三個文件分別如下:1.logon.jsp<%@page contentType="text/html" pageEncoding="UTF-8"%> http://www.w3.org/TR/html4/loose.dtd"> JSP Page 用戶名 密碼 2.Logon.java(Servlet)import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class Logon extends HttpServlet implements Filter { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name = request.getParameter("name"); String password = request.getParameter("password"); request.getSession().setAttribute("user", name + " " + password); System.err.println(name + " " + password); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } public String getServletInfo() { return "Short description"; } public void init(FilterConfig arg0) throws ServletException { } public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { try { request.setCharacterEncoding("UTF-8");//設置編碼 ((HttpServletResponse) response).setHeader("Pragma", "No-cache"); ((HttpServletResponse) response).setHeader("Cache-Control", "no-cache"); ((HttpServletResponse) response).setHeader("Expires", "0");//禁止緩存 filterChain.doFilter(request, response); } catch (ServletException sx) { } catch (IOException iox) { } }}3.web.xml ?xml version="1.0" encoding="UTF-8"? http://java.sun.com/xml/ns/javaee" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> Logon Logon Logon /Logon 30 index.jsp 接分,呵呵。
2. JSP編程題目求答案
publicclassRectangle{
privateIntegerrLength;//長
privateIntegerrWidth;//寬
privateIntegerrArea;//面積
publicIntegergetrLength(){
returnrLength;
}
publicvoidsetrLength(IntegerrLength){
this.rLength=rLength;
}
publicIntegergetrWidth(){
returnrWidth;
}
publicvoidsetrWidth(IntegerrWidth){
this.rWidth=rWidth;
}
publicIntegergetrArea(){
returnrArea;
}
publicvoidsetrArea(IntegerrArea){
this.rArea=rArea;
}
}
<%@pagelanguage="java"contentType="text/html;charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPEhtml>
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8">
<metaname="renderer"content="webkit|ie-comp|ie-stand">
<metahttp-equiv="X-UA-Compatible"content="IE=edge,chrome=1">
<metaname="viewport"
content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<metahttp-equiv="Cache-Control"content="no-siteapp"/>
<scripttype="text/javascript"src="jquery/1.9.1/jquery.min.js"></script>
<title></title>
</head>
<body>
<div>
<formaction="/xxxxxxxx"method="post"id="form-depart-edit">
<div>
<label><span>*</span>長:</label>
<div>
<inputtype="text"class="input-text"value=""placeholder="長"id="rLength"name="rLength">
</div>
</div>
<div>
<label><span>*</span>寬:</label>
<div>
<inputtype="text"class="input-text"value=""placeholder="寬"id="rWidth"name="rWidth">
</div>
</div>
<div>
<label><span>*</span>面積:</label>
<div>
<inputtype="text"value=""placeholder="面積"id="rArea"name="rArea"readonly="readonly">
</div>
</div>
<div>
<buttononClick="jisuan();"type="button">提交</button>
</div>
</form>
</div>
<scripttype="text/javascript">
functionjisuan(){
varrLength=$("#rLength").val();
varrWidth=$("#rWidth").val();
if(rWidth==null||rWidth==""||rLength==null||rLength==""){
alert("必須填寫長、寬!");
returnfalse;
}
varrArea=rLength*rWidth;
$("#rArea").val(rArea);
$("#form-depart-edit").submit();
}
</script>
</body>
</html>
3. JSP實用教程(第二版)課後習題答案
jsp的答案是:抄
你在刪除那裡寫個連接,然後將該行的id獲得
<a href="DelUserServlet?id=<%=((User)users.get(i)).getId()%>">刪除</a>
再在servlet裡面取這個id
String id=request.getParameter("id");
關於資料庫,你應該將book的狀態設置成默認為沒借,這個類型可以聲明成int,比如,0代表沒借1代表借了,這樣添加的書本都是沒借的才合理
至於第3個表裡面要有id,還要有用戶賬號,圖書id,
去這里參考一下:http://ishare.iask.sina.com.cn/search.php?key=JSP%CA%B5%D3%C3%BD%CC%B3%CC&format=
4. jsp程序設計教程課後習題答案
checkRegis.jsp頁
給你寫一部分參考一下吧
<%
String uname=request.getParameter("取值");
String upass=request.getParameter("取值");
if(uname.equls("user")){
%>
<script type="text/javascript">
alert("該用戶已經注冊",window.location.href="register.jsp");
</script>
<%
}
%>