jsp聊天系统没有使用数据库的简单介绍

本文目录一览:

代码怎么建立mysql数据库,朋友给了我一个JSP系统,可是没有数据库。怎么样建立的数据库才和系统吻合

这样做比较费劲,首先你得看他的JSP系统是如何调用数据库的,同时还得看JSP系统是直接读取或写入数据库字段的还是通过存储过程读取或写入数据库的,如果是直接读取的那根据JSP系统的字段名称及类型建立数据库中的表结构,如果是通过存储过程操作数据库的那就复杂了(如果是存储过程调用的话,劝你还是放弃该系统,因为这样你完全不知道数据库的表结构)

jsp+servlet 用户登录 不用数据库。新手java自学一个星期,求大神帮助。非常感谢!

你应该先判断一下那个req.getParameter(“name”)和那个req.getParameter(“name”)是否为空.如果不判断的话,它就会报那个语法错误的,因为这个页面一打开的话,req.getParameter(“name”)和

req.getParameter(“name”)!=null并没有被赋值,所以为空,肯定报错的;

代码应该这样写的:

if(req.getParameter(“name”)!=nullreq.getParameter(“name”)!=null){

String uname=req.getParameter(“name”);

String umm=req.getParameter(“mm”);

if(name.equals(uname)mm.equals(umm))

{

res.sendRedirect(“main.jsp”);

}

else

{

res.sendRedirect(“fail.jsp”);

}

}

用Jsp编写无数据库连接的简单公共聊天室,用application和list相关知识编写,请帮忙编写一下。

JSP页面:

%@ page language=”java” import=”java.util.*” pageEncoding=”gbk”%

%

String path = request.getContextPath();

String basePath = request.getScheme() + “://”

+ request.getServerName() + “:” + request.getServerPort()

+ path + “/”;

%

!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”

html

head

base href=”%=basePath%”

titleMy JSP ‘index.jsp’ starting page/title

meta http-equiv=”pragma” content=”no-cache”

meta http-equiv=”cache-control” content=”no-cache”

meta http-equiv=”expires” content=”0″

meta http-equiv=”keywords” content=”keyword1,keyword2,keyword3″

meta http-equiv=”description” content=”This is my page”

!–

link rel=”stylesheet” type=”text/css” href=”styles.css”

/head

body

form action=”DoApplication” method=”post”

输入聊天信息:

br /

textarea name=”talk” rows=”5″ cols=”40″/textarea

br /

input type=”submit” value=”确认”

input type=”reset” value=”清空”

/form

hr /

已有的聊天信息:

br /

%

List app = null;

app = (List) application.getAttribute(“app”);

if (app != null) {

%

textarea rows=”10″ cols=”40″ style=”text-align: left”

%

Iterator ite = app.iterator();

while (ite.hasNext()) {

String info = (String) ite.next();

%

%=info%

%

}

}

%

/textarea

/body

/html

————————————————

Severlet:

public class DoApplication extends HttpServlet {

/**

* Constructor of the object.

*/

public DoApplication() {

super();

}

/**

* Destruction of the servlet. br

*/

public void destroy() {

super.destroy(); // Just puts “destroy” string in log

// Put your code here

}

/**

* The doGet method of the servlet. br

*

* This method is called when a form has its tag value method equals to get.

*

* @param request the request send by the client to the server

* @param response the response send by the server to the client

* @throws ServletException if an error occurred

* @throws IOException if an error occurred

*/

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

String info=(String)request.getParameter(“talk”);

ServletContext application = this.getServletContext();

List appList=null;

appList=(List)application.getAttribute(“app”);

if(appList!=null){

appList.add(info);

}else{

appList=new ArrayList();

appList.add(info);

}

application.setAttribute(“app”, appList);

response.setCharacterEncoding(“gbk”);

request.getRequestDispatcher(“index.jsp”).forward(request, response);

}

/**

* The doPost method of the servlet. br

*

* This method is called when a form has its tag value method equals to post.

*

* @param request the request send by the client to the server

* @param response the response send by the server to the client

* @throws ServletException if an error occurred

* @throws IOException if an error occurred

*/

public void doPost(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

this.doGet(request, response);

}

/**

* Initialization of the servlet. br

*

* @throws ServletException if an error occurs

*/

public void init() throws ServletException {

// Put your code here

}

}

原创文章,作者:NDJV,如若转载,请注明出处:https://www.506064.com/n/145739.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
NDJVNDJV
上一篇 2024-10-27 23:52
下一篇 2024-10-27 23:52

相关推荐

  • Deepin系统分区设置教程

    本教程将会详细介绍Deepin系统如何进行分区设置,分享多种方式让您了解如何规划您的硬盘。 一、分区的基本知识 在进行Deepin系统分区设置之前,我们需要了解一些基本分区概念。 …

    编程 2025-04-29
  • Python 常用数据库有哪些?

    在Python编程中,数据库是不可或缺的一部分。随着互联网应用的不断扩大,处理海量数据已成为一种趋势。Python有许多成熟的数据库管理系统,接下来我们将从多个方面介绍Python…

    编程 2025-04-29
  • Python简单数学计算

    本文将从多个方面介绍Python的简单数学计算,包括基础运算符、函数、库以及实际应用场景。 一、基础运算符 Python提供了基础的算术运算符,包括加(+)、减(-)、乘(*)、除…

    编程 2025-04-29
  • openeuler安装数据库方案

    本文将介绍在openeuler操作系统中安装数据库的方案,并提供代码示例。 一、安装MariaDB 下面介绍如何在openeuler中安装MariaDB。 1、更新软件源 sudo…

    编程 2025-04-29
  • Python满天星代码:让编程变得更加简单

    本文将从多个方面详细阐述Python满天星代码,为大家介绍它的优点以及如何在编程中使用。无论是刚刚接触编程还是资深程序员,都能从中获得一定的收获。 一、简介 Python满天星代码…

    编程 2025-04-29
  • 如何在树莓派上安装Windows 7系统?

    随着树莓派的普及,许多用户想在树莓派上安装Windows 7操作系统。 一、准备工作 在开始之前,需要准备以下材料: 1.树莓派4B一台; 2.一张8GB以上的SD卡; 3.下载并…

    编程 2025-04-29
  • Java任务下发回滚系统的设计与实现

    本文将介绍一个Java任务下发回滚系统的设计与实现。该系统可以用于执行复杂的任务,包括可回滚的任务,及时恢复任务失败前的状态。系统使用Java语言进行开发,可以支持多种类型的任务。…

    编程 2025-04-29
  • Python海龟代码简单画图

    本文将介绍如何使用Python的海龟库进行简单画图,并提供相关示例代码。 一、基础用法 使用Python的海龟库,我们可以控制一个小海龟在窗口中移动,并利用它的“画笔”在窗口中绘制…

    编程 2025-04-29
  • 数据库第三范式会有删除插入异常

    如果没有正确设计数据库,第三范式可能导致删除和插入异常。以下是详细解释: 一、什么是第三范式和范式理论? 范式理论是关系数据库中的一个规范化过程。第三范式是范式理论中的一种常见形式…

    编程 2025-04-29
  • 分销系统开发搭建

    本文主要介绍如何搭建一套完整的分销系统,从需求分析、技术选型、开发、部署等方面进行说明。 一、需求分析 在进行分销系统的开发之前,我们首先需要对系统进行需求分析。一般来说,分销系统…

    编程 2025-04-29

发表回复

登录后才能评论