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

热点内容
java网页能做心跳机制 浏览:817
逆战文件应用在哪里 浏览:102
红头文件订书红线在哪里 浏览:851
excel怎么做文件头 浏览:703
为什么word找不到文件菜单 浏览:671
ios15安装后找不到描述文件 浏览:440
学编程怎么学最有效 浏览:873
通过wifi传文件到ipad 浏览:197
js随机颜色 浏览:611
文件快速复制到u盘的软件 浏览:443
如何检查无线网络驱动是否正常 浏览:468
百度网盘来自分享的文件在哪里 浏览:127
如何发视频到腾讯视频文件夹里 浏览:510
微信打开cad外部文件找不到 浏览:882
平板可以打开各种文件后缀的软件 浏览:531
苹果微信文件怎么全选 浏览:749
手机里之前打开过的文件在哪里找 浏览:685
cad能看word文件吗 浏览:719
12306火车票系统后台数据库 浏览:570
js翻译德语 浏览:33

友情链接