JSP實現驗證碼

image.jsp


輸出時應用驗證碼

 

<script>

document.write("<img border=0 src='/image.jsp?Rand="+Math.random()*10000+" '>");

</script>

<br>
   輸認證碼:<input name="Rand" maxlength=4 size="10">

<br>

 

登錄認證:

 String Rand=request.getParameter("Rand");
 String strRand=(String)session.getAttribute("Rand");
 if(!strRand.equals(Rand))
 
  //未通過;
 }


附註:其實Rand.trim()更好

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章