云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 中南民族大学JavaEE实验报告(聊天室,购物车)

中南民族大学JavaEE实验报告(聊天室,购物车)

  • 62 次阅读
  • 3 次下载
  • 2025/5/24 13:54:36

/*

* To change this template, choose Tools | Templates * and open the template in the editor. */

package com.servlet;

import java.io.IOException; import java.io.PrintWriter; import javax.servlet.*; import javax.servlet.http.*; /** *

* @author huxiao */

public class loginsucess extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //TODO Method stub generated by Lomboz response.setContentType(\

String name=request.getParameter(\ HttpSession session=request.getSession();

String history =(String)getServletContext().getAttribute(\ if(history==null) history=\

String temp =(String)getServletContext().getAttribute(\ if(temp==null) temp=\

PrintWriter out = response.getWriter(); try{

out.println(\http-equiv=\\\content=\\%url=response.encodeURL(\\\

out.println(\

out.println(\ align=\\\欢迎来到聊天室 \

out.println(\bgcolor=#00aabb behavior=alternate><<<<<<<<希望大家聊的开心>>>>>>>\

out.println (\在线人数:\历史访问次数:\ out.println(\

String tempHistory=(String)getServletContext().getAttribute(\ if(tempHistory==null) tempHistory=\

out.println(\cols=\\\ rows=\\\name=\\\style=\\\ out.println(); out.println(\ out.println(\

out.println(\ out.println(\ cols=\\\ rows=\\\style=\\\name=\\\

out.println(\

out.println(\ name=\\\发送\\\ out.println(\ name=\\\取消\\\ out.println(\

out.println(\ }finally{ out.close(); } }

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); }

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

HttpSession session=request.getSession();

String user=request.getParameter(\

session.setAttribute(\ processRequest(request,response); } }

5、 登录失败 faillogin.java /*

* To change this template, choose Tools | Templates * and open the template in the editor. */

package com.servlet;

import java.io.*;

import javax.servlet.*; import javax.servlet.http.*; /** *

* @author huxiao */

public class loginfail extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //TODO Method stub generated by Lomboz doPost(request,response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //TODO Method stub generated by Lomboz response.setContentType(\ PrintWriter out = response.getWriter(); out.println(\

out.println(\ out.println(\ out.println(\登录失败\ out.println(\ out.println(\ out.println(\ out.println(\登录失败!!!请重新登录。。。\

RequestDispatcher dispatcher =request.getRequestDispatcher(\ dispatcher.include(request, response); out.println(\ out.println(\ out.close(); } }

6、 任务监听 sessionListener.java

/*

* To change this template, choose Tools | Templates * and open the template in the editor. */

package com.servlet;

import javax.servlet.annotation.WebListener; import javax.servlet.http.HttpSessionEvent; import javax.servlet.http.HttpSessionListener; /**

* Web application lifecycle listener. *

* @author Josh */

@WebListener()

public class SessionListener implements HttpSessionListener {

@Override

public void sessionCreated(HttpSessionEvent se) {

String current=(String)se.getSession().getServletContext().getAttribute(\ if(current==null) current=\

int c=Integer.parseInt(current); c++;

current=String.valueOf(c);

se.getSession().getServletContext().setAttribute(\

String his=(String)se.getSession().getServletContext().getAttribute(\ if(his==null) his=\

int total=Integer.parseInt(his)+1; his=String.valueOf(total);

se.getSession().getServletContext().setAttribute(\ }

@Override

public void sessionDestroyed(HttpSessionEvent se) {

String current=(String)se.getSession().getServletContext().getAttribute(\ if(current==null) current=\

int c=Integer.parseInt(current); c--;

current=String.valueOf(c);

se.getSession().getServletContext().setAttribute(\ } }

7、 计数文件 CountFile.java

/*

* To change this template, choose Tools | Templates * and open the template in the editor. */

package com.servlet; import java.io.*; /** *

* @author huxiao */

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.*; import javax.servlet.http.*; /** * * @author huxiao */ public class loginsucess extends HttpServlet { protected void processRequest(HttpServl

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com