導航:首頁 > 編程語言 > jsp上機操作題

jsp上機操作題

發布時間:2023-06-03 19:31:23

㈠ 幾道jsp編程題,求大神幫忙做一下,謝謝了!

publicclassStudents{
privateStringsid;
privateStringsname;
privateintage;
privatecharsex;

publicStringgetSid(){
returnsid;
}

publicvoidsetSid(Stringsid){
this.sid=sid;
}

publicStringgetSname(){
returnsname;
}

publicvoidsetSname(Stringsname){
this.sname=sname;
}

publicintgetAge(){
returnage;
}

publicvoidsetAge(intage){
this.age=age;
}

publicchargetSex(){
returnsex;
}

publicvoidsetSex(charsex){
this.sex=sex;
}
@Override
publicinthashCode(){
finalintprime=31;
intresult=1;
result=prime*result+age;
result=prime*result+sex;
result=prime*result+((sid==null)?0:sid.hashCode());
result=prime*result+((sname==null)?0:sname.hashCode());
returnresult;
}

㈡ JSP編程題目求答案

java">
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>

㈢ jsp 試題

Calculator:
public class Calculator {
private Double a;
private Double b;
private String operator;
public Double getA() {
return a;
}
public void setA(Double a) {
this.a = a;
}
public Double getB() {
return b;
}
public void setB(Double b) {
this.b = b;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
}

Controller:
public class Controller extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String op=request.getParameter("op");
if ("+".equals(op)) {
request.getRequestDispatcher("add").forward(request, response);
}
}

}
AddAction:
public class AddAction extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String a=request.getParameter("a");
String b=request.getParameter("b");
request.setAttribute("rlt", Integer.parseInt(a)+Integer.parseInt(b));
request.getRequestDispatcher("rlt.jsp").forward(request, response);
}

}
add.jsp
<%@ page language="java" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'add.jsp' starting page</title>
</head>

<body>
<form action="${pageContext.request.contextPath}/Controller">
數a:<input type="text" name="a"><br>
數b:<input type="text" name="b"><br>
<input type="radio" name="op" value="+">+
<input type="radio" name="op" value="-">-<br>
<input type="submit" value="計算">
</form>
</body>
</html>
rlt.jsp:
<%@ page language="java" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'add.jsp' starting page</title>
</head>

<body>
${rlt }
</body>
</html>

㈣ 關於一些JSP程序設計的問答題,我不懂。幫幫忙。

1:servlet
2:在JSP的3種指令中,用來定義與頁面相關屬性的指令是(page ),回用於在JSP頁面中包括另一個文件的答指令是( include ),3: <jsp:include>
4: GB2312
5:<%-- 這是注釋的內容 --%>
6 A 指令元素是:<%@ %>
7 A 當成字元串來輸出
8 B D都對 A是因為Int 的i應該小寫 <%=%>這是表達式的寫法,後不用加冒號
9:D
10:B import用來導入包和類的
11:D <%@ include file="relativeURL"%>這是jsp的指令元素

㈤ jsp編程題

就好了,完整代碼如下,記得jar驅動放好,如果輸出的是內存地址的話就證明配置沒問題,不然就是你的操作或者配置問題了:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class BaseDao {
private static final String DRIVER_CLASS="com.microsoft.sqlserver.jdbc.SQLServerDriver";
private static final String URL="jdbc:sqlserver://localhost:1433;DATABASENAME=managerNews";
private static final String UNAME="sa";
private static final String UPASSWORD="sa";

/*
* 連接資料庫
*/
public Connection getConnection(){
Connection conn=null;
try {
Class.forName(DRIVER_CLASS);
conn=DriverManager.getConnection(URL,UNAME,UPASSWORD);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return conn;
}
/*
* 關閉conn,ps,rs,釋放資源
*/
public void closeAll( Connection conn, PreparedStatement ps, ResultSet rs ) {
/* 如果rs不空,關閉rs */
if(rs != null){
try catch (SQLException e)
}
/* 如果pstmt不空,關閉pstmt */
if(ps!= null){
try catch (SQLException e)
}
/* 如果conn不空,關閉conn */
if(conn != null){
try catch (SQLException e)
}
}

// public static void main (String[] args){
//
// BaseDao bo= new BaseDao();
// Connection conn=null;
// conn=bo.getConnection();
// System.out.print(conn);
//
// }
}

閱讀全文

與jsp上機操作題相關的資料

熱點內容
word使用教程下載 瀏覽:295
電腦文件平鋪圖片默認大小 瀏覽:115
文件查看設置信息失敗 瀏覽:668
編程如何編出烏鴉喝水的課文 瀏覽:20
國家反詐app報案助手怎麼使用 瀏覽:439
秘密文件丟失多少天 瀏覽:237
js中csstext 瀏覽:382
目標文件名過長復制 瀏覽:892
樂動力計步器老版本 瀏覽:933
壓縮文件鏈接怎麼編輯 瀏覽:808
如何鎖定PDF文件里的圖章 瀏覽:89
資料庫超時是什麼 瀏覽:649
文件怎麼改整列內容 瀏覽:764
360壓縮文件發郵件空白 瀏覽:813
上哪裡查自己大數據 瀏覽:907
編程語言怎麼學車 瀏覽:189
編程該怎麼學才能先找工作 瀏覽:524
文件刻制光碟多少錢 瀏覽:861
校園網的網路組成結構 瀏覽:862
u盤系統復制文件過大 瀏覽:843

友情鏈接