导航:首页 > 编程语言 > 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上机操作题相关的资料

热点内容
cad文件为什么显示文件名是否正确 浏览:174
程序配置文件能自动转换成txt 浏览:985
r4烧录卡不同版本 浏览:962
怎么升级qq群为2000 浏览:347
微信己册除的文件怎样找回来 浏览:715
苹果美国账号共享2017 浏览:252
ps文件修改后打开还是原图 浏览:220
烧卡机苹果4微信qq哪里下载 浏览:780
ug120找不到指定文件 浏览:522
cda文件怎么转换成mp3格式 浏览:702
青岛hpv疫苗在哪个app预约 浏览:881
双十一成交额2021数据在哪里看 浏览:631
苹果手机怎么打开移动数据 浏览:637
文件扫描成图片是彩色的吗 浏览:50
编程里的comply什么意思 浏览:91
电脑上面点了禁用网络怎么改回来 浏览:28
javacatch执行 浏览:182
ps软件文件名字 浏览:184
黑苹果查找文件路径 浏览:397
现在编程都有哪些语言 浏览:360

友情链接