twol吧 关注:27贴子:701
  • 4回复贴,共1

【twol】【JSP专区】jsp页面中如何加入验证码

只看楼主收藏回复

一楼百度


IP属地:陕西1楼2011-10-11 13:00回复
    需要三个页面:
    index.jsp 要显示验证码的页面
    safecode.jsp 调用验证码,更换验证码
    safecode.java servlet页面,用来生成验证码


    IP属地:陕西2楼2011-10-11 13:02
    回复
      广告
      立即查看
      index.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%>">
      <title>index</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">
      <script type="text/javascript">
      </script>
      </head>
      <body>
      <form>
      <iframe src="safecode.jsp" width=150 height=35 frameborder="0" scrolling="No"></iframe>
      </form>
      </body>
      </html>


      IP属地:陕西3楼2011-10-11 13:08
      回复
        safecode.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%>">
        <title>safecode</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">
        -->
        <style type="text/css"></style>
        </head>
        <body>
        <img border="0" src="servlet/safecode" id="safecode">
        <a href="javascript:window.location.reload()">换一张</a>
        </body>
        </html>


        IP属地:陕西4楼2011-10-11 13:16
        回复



          IP属地:陕西5楼2011-10-11 13:30
          回复