1.在运行WEB项目时,IE提示‘404’错误,不可能的原因包括()。
A/未启动TOMCAT服务
B/未部署WEB项目
C/URL中的上下文了路径书写错误
D/URL中的文件名称书写错误2.JSP网页文件的拓展名是
A/JAVA
B/CLASS
C/JSP
D/ASP 3.假设已经获得ResultSet对象RS,那么获取第一行数据的正确语句是
A/RE.HASNEXT()
B/rs.next()
C/rs.nextROW()
D/rs.hasNextROW() 4.下列选项中,合法的表达式有
A/ <%X%>
B/ <%=Math.random();%>
C/ <%="4"+"2" %>
D/ < % String x="4"+"2";%> 5.在某个JSP页面中存在这样一行代码;<% 1+3; %>,运行该JSP后,以下说法正确的是
A.这行代码没有对应的输出
B.这行代码对应的输出是;4
C.这行代码对应的输出是;1+3
D.这行代码将引发错误 6.JSP内置对象REQUEST的request的getparametervalues()方法的返回值是 A
A.String[]
B.Object[]
C.String
D.Object7.关于表单发送信息的两种法师GET和POST,一下说法正确的是()
A.GET是表单发送信息的默认方法。
B.POST是表单发送信息的默认方法。
C.使用POST方式发送信息,在地址栏里可以看到表单内容。
D.以上都正确 8.试图运行如下JSP代码,一下说法正确的是()
<html>
<%
String str="hello ACCP";
Session.setAttribute("title",str);
String getStr=session.getAttribute("title");
out.println(getStr);
%>
</html>
A.运行成功,页面上输出hello ACCP
B.运行成功,页面上输出title
C.代码行 session.setAttribute("title",str);有错误,无法运行
D.代码行 session.getStr=session.getAttribute("title");有错误,无法运行 9.JSP提供了可以称之为“会话”的内置对象可以在多个请求之间持续有效()。
A.request
B.response
C.session
D.application 10.out.print()的功能是
A.输出数据
B.输入数据
C.SERVLET 对象
D.错误对象 二,填空题
1.JSP把(JAVA)作为默认的脚本语言。
2.写出常用的隐式对象有哪些(任意写5个)(page)(resquest)(response)(session)(config)。
3.输出到浏览器的注释格式为(7);服务器端的JSP注释格式为(8)。
4、JSP中的数据类型可以分为基本数据类型与符合数据类型。基本数据类型有四类;(9)(10)(11)和(12)。
5.Page指令的(import)属性指明想要引入的包和类:(contentType)属性用于设置JSP文件和最终文件的MTME类型和字符集的类型(如:"gb312");
6.常用的数据库驱动方式有(JDBC-ODBC)和(native api/partly java bridge)。
7.JDBC对数据库的操作通过5个JDBC的类/接口来实现,他们是数据库的JDBC驱动器类,(17)(18)(19)和(20)。 三,简答题
1,编写一个JSP页面,使用驯悍显示100行100列的表格。1.代码如下 100*100的表格 宽度为1
<%@ page contentType = "text/html; charset = GBK" %>
<html><head><title>第2页</title></head>
<body>
<table border=1>
<%
for(int i = 1 ;i<=100;i++)
{
%>
<tr>
<%
for(int j=1;j<=100;j++)
{
%>
<td>
</td>
<%
}
%>
</tr>
<%
}
%>
</table>
</body>
</html> 2,给定程序所显示的页面保存了用户“LINING”的姓名,并可输入年龄。请设计出该JSP页面中要激活的第2个页面“Second.jsp”,要求在第2个页面中获取并且显示用户的姓名和年龄。
<%@ page contentType = "text/html; charset = gb2312" pageEncoding=" gb2312" %>
<html><body<>head><title>第1页</title></head>
<%session.setAttribute("name","LINING");//保存姓名%>
<form method = post action = "Second.jsp">
请输出您的年龄;
<br><input name= "age" size="12">
<p>
<input type = submit value = "确定">
</form></body></html>
<%@ page contentType = "text/html; charset = gb2312" pageEncoding=" gb2312" %>
<html><head><title>第2页</title></head>
<body>
<%
String age=request.getParameter("age");
%>
姓名:<%=session.getAttribute("name")%>
年龄:<%=age%>
</body>
</html>
3.根据所学知识,设计一个登陆验证系统,要求说明各个文件的功能,数据库写出相关表名和字段名,其他文件写出关键代码。 login.jsp 登录页面
checkLogin.jsp 登录验证
数据库: user
id 自动增长
name String
password String
关键代码
package ckstudio.db;
import java.sql.*;
public class mysqlconn2 {
String sDBDriver = "org.gjt.mm.mysql.Driver";
//请修改下面参数--数据地址:localhost 数据库名:jspshop 用户名:root 密码:root
String sConnStr = "jdbc:mysql://localhost:3306/jspshop?user=root&password=root&useUnicode=true&characterEncoding=GB2312";
Connection conn = null;
ResultSet rs = null;
public mysqlconn2() {
try {
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("conn(): " + e.getMessage());
}
}
public void executeInsert(String sql)
{
try
{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement(); int n=stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println("conn.executeUpdate:"+ ex.getMessage());
}
}
public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(sConnStr);
Statement stmt;
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
public void executeDelete(String sql)
{
try
{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println("conn.executeDelete: "+ ex.getMessage());
}
}
public int executeUpdate(String sql)
{
int n=0;
try
{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement();
n=stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println("conn.executeDelete: "+ ex.getMessage());
}
return n;
}
public void Close()
{
try{
if(rs!=null)
{
rs.close();
}
if(conn!=null)
{
conn.close();
}
}
catch(SQLException ex)
{
System.err.println("conn.executeDelete: "+ ex.getMessage());
} }
}
A/未启动TOMCAT服务
B/未部署WEB项目
C/URL中的上下文了路径书写错误
D/URL中的文件名称书写错误2.JSP网页文件的拓展名是
A/JAVA
B/CLASS
C/JSP
D/ASP 3.假设已经获得ResultSet对象RS,那么获取第一行数据的正确语句是
A/RE.HASNEXT()
B/rs.next()
C/rs.nextROW()
D/rs.hasNextROW() 4.下列选项中,合法的表达式有
A/ <%X%>
B/ <%=Math.random();%>
C/ <%="4"+"2" %>
D/ < % String x="4"+"2";%> 5.在某个JSP页面中存在这样一行代码;<% 1+3; %>,运行该JSP后,以下说法正确的是
A.这行代码没有对应的输出
B.这行代码对应的输出是;4
C.这行代码对应的输出是;1+3
D.这行代码将引发错误 6.JSP内置对象REQUEST的request的getparametervalues()方法的返回值是 A
A.String[]
B.Object[]
C.String
D.Object7.关于表单发送信息的两种法师GET和POST,一下说法正确的是()
A.GET是表单发送信息的默认方法。
B.POST是表单发送信息的默认方法。
C.使用POST方式发送信息,在地址栏里可以看到表单内容。
D.以上都正确 8.试图运行如下JSP代码,一下说法正确的是()
<html>
<%
String str="hello ACCP";
Session.setAttribute("title",str);
String getStr=session.getAttribute("title");
out.println(getStr);
%>
</html>
A.运行成功,页面上输出hello ACCP
B.运行成功,页面上输出title
C.代码行 session.setAttribute("title",str);有错误,无法运行
D.代码行 session.getStr=session.getAttribute("title");有错误,无法运行 9.JSP提供了可以称之为“会话”的内置对象可以在多个请求之间持续有效()。
A.request
B.response
C.session
D.application 10.out.print()的功能是
A.输出数据
B.输入数据
C.SERVLET 对象
D.错误对象 二,填空题
1.JSP把(JAVA)作为默认的脚本语言。
2.写出常用的隐式对象有哪些(任意写5个)(page)(resquest)(response)(session)(config)。
3.输出到浏览器的注释格式为(7);服务器端的JSP注释格式为(8)。
4、JSP中的数据类型可以分为基本数据类型与符合数据类型。基本数据类型有四类;(9)(10)(11)和(12)。
5.Page指令的(import)属性指明想要引入的包和类:(contentType)属性用于设置JSP文件和最终文件的MTME类型和字符集的类型(如:"gb312");
6.常用的数据库驱动方式有(JDBC-ODBC)和(native api/partly java bridge)。
7.JDBC对数据库的操作通过5个JDBC的类/接口来实现,他们是数据库的JDBC驱动器类,(17)(18)(19)和(20)。 三,简答题
1,编写一个JSP页面,使用驯悍显示100行100列的表格。1.代码如下 100*100的表格 宽度为1
<%@ page contentType = "text/html; charset = GBK" %>
<html><head><title>第2页</title></head>
<body>
<table border=1>
<%
for(int i = 1 ;i<=100;i++)
{
%>
<tr>
<%
for(int j=1;j<=100;j++)
{
%>
<td>
</td>
<%
}
%>
</tr>
<%
}
%>
</table>
</body>
</html> 2,给定程序所显示的页面保存了用户“LINING”的姓名,并可输入年龄。请设计出该JSP页面中要激活的第2个页面“Second.jsp”,要求在第2个页面中获取并且显示用户的姓名和年龄。
<%@ page contentType = "text/html; charset = gb2312" pageEncoding=" gb2312" %>
<html><body<>head><title>第1页</title></head>
<%session.setAttribute("name","LINING");//保存姓名%>
<form method = post action = "Second.jsp">
请输出您的年龄;
<br><input name= "age" size="12">
<p>
<input type = submit value = "确定">
</form></body></html>
<%@ page contentType = "text/html; charset = gb2312" pageEncoding=" gb2312" %>
<html><head><title>第2页</title></head>
<body>
<%
String age=request.getParameter("age");
%>
姓名:<%=session.getAttribute("name")%>
年龄:<%=age%>
</body>
</html>
3.根据所学知识,设计一个登陆验证系统,要求说明各个文件的功能,数据库写出相关表名和字段名,其他文件写出关键代码。 login.jsp 登录页面
checkLogin.jsp 登录验证
数据库: user
id 自动增长
name String
password String
关键代码
package ckstudio.db;
import java.sql.*;
public class mysqlconn2 {
String sDBDriver = "org.gjt.mm.mysql.Driver";
//请修改下面参数--数据地址:localhost 数据库名:jspshop 用户名:root 密码:root
String sConnStr = "jdbc:mysql://localhost:3306/jspshop?user=root&password=root&useUnicode=true&characterEncoding=GB2312";
Connection conn = null;
ResultSet rs = null;
public mysqlconn2() {
try {
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("conn(): " + e.getMessage());
}
}
public void executeInsert(String sql)
{
try
{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement(); int n=stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println("conn.executeUpdate:"+ ex.getMessage());
}
}
public ResultSet executeQuery(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(sConnStr);
Statement stmt;
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
public void executeDelete(String sql)
{
try
{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println("conn.executeDelete: "+ ex.getMessage());
}
}
public int executeUpdate(String sql)
{
int n=0;
try
{
conn=DriverManager.getConnection(sConnStr);
Statement stmt=conn.createStatement();
n=stmt.executeUpdate(sql);
}
catch(SQLException ex)
{
System.err.println("conn.executeDelete: "+ ex.getMessage());
}
return n;
}
public void Close()
{
try{
if(rs!=null)
{
rs.close();
}
if(conn!=null)
{
conn.close();
}
}
catch(SQLException ex)
{
System.err.println("conn.executeDelete: "+ ex.getMessage());
} }
}
解决方案 »
- 为什么eclipse中编译后的servlet是放在build目录下,而不是web-inf目录下?需要转移到web-inf目录吗?
- 紧急求救!关于POST参数构建....
- 使用cxf 生成 wsdl xmlns:tns 没有在wsdl:definitions 中
- jxl问题,急呀,帮忙,
- 多行数据怎么保存----最好用javabean实现
- eclipse为什么debug打上断点后,运行到断点那行不变色
- 页面刷新问题 求教
- servlet 怎样输出图片
- 为什么往Vector中加Hashtable出错!
- 现有一6000元的jsp项目
- 分享:关于GWT
- 请大家推荐个展示速度快且易上手的免费报表工具,谢谢!
0分也能发帖?CSDN不拦截的吗?
accp害人啊很好奇楼主0分怎么发帖的