JSP实现成语接龙

首页: 

<%--
  Created by IntelliJ IDEA.
  User: zdd
  Date: 2019/11/18
  Time: 10:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


    成语接龙首页


四字成语接龙
你输入的成语为: <% String s = (String)application.getAttribute("message"); if(s!=null){ out.println(s); }else{ out.println("还没有成语,请输入:
"); } %>

输入成语:

处理页面 

<%--
  Created by IntelliJ IDEA.
  User: zdd
  Date: 2019/11/18
  Time: 10:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>


    jielong.jsp


<%!
    String message = "";
    ServletContext application;
    synchronized void sendmessage(String s){
        application= getServletContext();
        message = message+s+"--->";
        application.setAttribute("message",message);
    }
%>
<%
    request.setCharacterEncoding("UTF-8");
    String content = request.getParameter("mess");
    sendmessage(content);
    out.println("你的成语"+content+"已经提交");
    response.setHeader("refresh","3;chengyu.jsp");
%>



运行结果:

JSP实现成语接龙_第1张图片

                                

          JSP实现成语接龙_第2张图片

 

 

你可能感兴趣的:(JavaWeb)