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>
<%
}
%>