web总结

javaweb

  1. 属于服务器的是(Tomcat)

  2. 题目未知(发送重定向,sendRedirect)

  3. 不属于原始类型的

double,float,byte,short,int,long,char,boolean属于原始类型

(String不是原始类型,怀疑考string)

  1. 下边哪个不属于容器container(A,Button)

A.Button B.Frame C.JFrame D.Jpanel

  1. 下边jsp内置对象

request,response,session,application,out,pageContext,page,config,Exception(前五个为重点)

  1. 页面编译指令page不能实现的是(C.页面跳转)

A设置页面当前的meta属性 B设置当前页面的出错处理 C.设置当前页面的跳转 D.设置当前页面引入的java程序包

  1. 浏览器禁用cookies,来得到sessionId

response.encodeURL

  1. tomcat中增加虚拟目录

(server.xml下的Context目录

  1. 浏览器访问地址是下列哪个标签对应的名称(C.url-partern)

A.server-name B.server-class C.url-parternD.Servlet-mapping

  1. 编写一个底层的响应访问请求servlet程序,应该覆盖哪个方法(service)

    (其中httpservlet重写的方法是doGet,doPost)

  2. JSTL标签库哪个可以数据输出格式定义(B)

A,核心库 B。i18N C.XML D.函数标签库

  1. 哪个组合的程序完全在服务器端执行的(C)

    A jsp+applet B。jsp+JavaScript C.jsp+servlet D。servlet+applet

  2. tomcat默认端口(8080)

  3. 如果改端口号应该在tomcat哪个文件(A.server.xml)

    A.server.xml B.web.xml C.tomcat.xml D.不能改

    简答题

    一。jsp哪些内置对象(9种内置对象)

    request,response,session,application,out,pageContext,page,config,Exception

    二。 过滤器filter实现原理,过滤器如何创建的和。。

    程序题
    不一定对,仅供借鉴
    一,用原生jdbc连接数据库

       <%@ page import="java.sql.*" %>
<%@ page language="java" contentType="text/html; charset=utf-8"
        %>
<html>

<%
    request.setCharacterEncoding("UTF-8");
    String name=request.getParameter("name");
    String age=request.getParameter("age");
    String email=request.getParameter("email");
    PreparedStatement statement=null;
    Connection conn=null;
        Class.forName("com.mysql.cj.jdbc.Driver");
         conn=DriverManager.getConnection
                (
                        "jdbc:mysql://localhost:3306/jdbctest?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone = GMT",
                        "root",
                        "root"
                );
        String sql="insert into exam (name,age,email) values (?,?,?)";
        statement=conn.prepareStatement(sql);
        statement.setObject(1,name);
        statement.setObject(2,age);
        statement.setObject(3,email);
        statement.executeUpdate();
        statement.close();
        conn.close();
    }
%>
<body>
<form action="javaWeb.jsp" method="POST">
    <h1>用户注册</h1>
    <p>
        姓名
        <input type="text" name="name" >
    </p>
    <p>
        年龄:
        <input type="number" name="age" >
    </p>
    <p>
        邮箱
        <input type="email" name="email">
    </p>
    <p >
        <input type="submit" value="注册">
    </p>
</form>
</body>
</html>

二、javabean登录和显示

student.java这个javabean

package com.Sakura.model;

public class Student {
    private String name;
    private String password;
    private int age;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}

jsp页面

<%@ page language="java" contentType="text/html;"
         pageEncoding="UTF-8"%>
<html>
<head>
    <title>javaBean</title>
</head>
<body>
<form action="exam.jsp" method="post">
姓名:<input type="text" name="name"><br>
年龄:<input type="text" name="age">
密码:<input type="password" name="password">
<input type="submit" value="提交">
</form>
<%request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean id="Student" scope="page" class="com.Sakura.model.Student"></jsp:useBean>
<%--<jsp:setProperty name="Student" property="*"></jsp:setProperty>--%>
<jsp:setProperty name="Student" property="name" param="name"/>
<jsp:setProperty name="Student" property="age" param="age"/>
<jsp:setProperty name="Student" property="password" param="password"/>
<h3>姓名:<jsp:getProperty name="Student" property="name" /></h3>
<h3>年龄:<jsp:getProperty name="Student" property="age" /></h3>
<h3>密码:<jsp:getProperty name="Student" property="password" /></h3>
</body>
</html>
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值