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

热点内容
彩视制作教程 浏览:766
圣墟在哪个App看免费 浏览:395
网络哪些不能玩 浏览:868
probe315使用教程 浏览:646
数字电位器程序 浏览:198
c代码整理 浏览:104
网络营销具有什么优势 浏览:378
右下角网络连接不显示宽带连接 浏览:940
ps修改tif文件 浏览:580
预防医学如何转行做大数据 浏览:234
pdf文件变蓝 浏览:309
怎么在pdf文件上面用k宝签名 浏览:213
如何知道表格里数据后面有空格 浏览:720
gee引擎更新系统找不到指定文件 浏览:802
贝壳网的数据删除了如何找回 浏览:509
华为荣耀6x怎么切换网络 浏览:418
手机里的pdf文件在哪放 浏览:889
java版贪吃蛇毕业论文 浏览:989
微信公共号邮箱 浏览:415
图片宽度代码 浏览:460

友情链接