functionStorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+" />

亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

驗(yàn)證碼

系統(tǒng) 2070 0
<script>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>
Add jcaptcha-all.jar (provided in bin-distribution ) and ehcache.jar (not provided see ehcache site ) to your application class path, ie in you WEB-INF/lib folder.

實(shí)例一個(gè)jcaptcha服務(wù),注意,必須是單例模式的
import com.octo.captcha.service.image.ImageCaptchaService;
import com.octo.captcha.service.image.DefaultManageableImageCaptchaService;

public class CaptchaServiceSingleton {

private static ImageCaptchaService instance = new DefaultManageableImageCaptchaService();

public static ImageCaptchaService getInstance(){
return instance;
}
}

注:以上是默認(rèn)的一個(gè)實(shí)現(xiàn),下面是其他更多的實(shí)現(xiàn)
  • SimpleListSoundCaptchaEngine //還可以用聲音,真爽哦
  • SpellerSoundCaptchaEngine
  • SpellerSoundCaptchaEngine
  • DefaultGimpyEngineCaptcha
  • BaffleListGimpyEngineCaptcha
  • BasicListGimpyEngineCaptcha
  • DeformedBaffleListGimpyEngineCaptcha
  • DoubleRandomListGimpyEngineCaptcha
  • SimpleListImageCaptchaEngineCaptcha
  • SimpleFishEyeEngineCaptcha
具體請(qǐng)參考 官方說明

編寫一個(gè)產(chǎn)生圖片的servlet


import com.octo.captcha.service.CaptchaServiceException;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;


public class ImageCaptchaServlet extends HttpServlet {


public void init(ServletConfig servletConfig) throws ServletException {

super .init(servletConfig);

}


protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {

byte [] captchaChallengeAsJpeg = null ;
// the output stream to render the captcha image as jpeg into
ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
try {
// get the session id that will identify the generated captcha.
// the same id must be used to validate the response, the session id is a good candidate!
String captchaId = httpServletRequest.getSession().getId();
// call the ImageCaptchaService getChallenge method
BufferedImage challenge =
CaptchaServiceSingleton.getInstance().getImageChallengeForID(captchaId,
httpServletRequest.getLocale());

// a jpeg encoder
JPEGImageEncoder jpegEncoder =
JPEGCodec.createJPEGEncoder(jpegOutputStream);
jpegEncoder.encode(challenge);
}
catch (IllegalArgumentException e) {
httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
return ;
}
catch (CaptchaServiceException e) {
httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return ;
}

captchaChallengeAsJpeg
= jpegOutputStream.toByteArray();

// flush it in the response
httpServletResponse.setHeader( " Cache-Control " , " no-store " );
httpServletResponse.setHeader(
" Pragma " , " no-cache " );
httpServletResponse.setDateHeader(
" Expires " , 0 );
httpServletResponse.setContentType(
" image/jpeg " );
ServletOutputStream responseOutputStream
=
httpServletResponse.getOutputStream();
responseOutputStream.write(captchaChallengeAsJpeg);
responseOutputStream.flush();
responseOutputStream.close();
}
}


為servlet修改web.xml配置文件
< servlet >
< servlet-name > jcaptcha </ servlet-name >
< servlet-class > ImageCaptchaServlet </ servlet-class >
< load-on-startup > 0 </ load-on-startup >
</ servlet >


< servlet-mapping >
< servlet-name > jcaptcha </ servlet-name >
< url-pattern > /jcaptcha </ url-pattern >
</ servlet-mapping >


編寫你的客戶端的展示
< img src ="jcaptcha" >
< input type ='text' name ='j_captcha_response' value ='' >

上面的src="jcaptcha" 就是調(diào)用了上面的servlet,text里是用戶填寫的確認(rèn)驗(yàn)證碼

后臺(tái)邏輯驗(yàn)證
Boolean isResponseCorrect = Boolean.FALSE;
// remenber that we need an id to validate!
String captchaId = httpServletRequest.getSession().getId();
// retrieve the response
String response = httpServletRequest.getParameter( " j_captcha_response " );
// Call the Service method
try {
isResponseCorrect
= CaptchaServiceSingleton.getInstance().validateResponseForID(captchaId,
response);
}
catch (CaptchaServiceException e) {
// should not happen, may be thrown if the id is not valid
}

驗(yàn)證碼


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 久久不雅视频 | 中文字幕日韩专区 | 波多野给衣一区二区三区 | 亚洲日本一区二区三区在线不卡 | 久久一级片 | 亚洲一区二区三区精品国产 | 视频二区精品中文字幕 | 成人xxxx| 久久网站免费观看 | 久久亚洲精品中文字幕亚瑟 | 日韩一区二区三区在线 | 国内精品51视频在线观看 | 亚洲网在线 | 狠狠的操你 | 福利网站在线播放 | 最新国产在线精品91尤物 | 99久久精品国产片久人 | 亚洲精品中文字幕在线 | 神马不卡伦影视 | 九九热这里只有精品6 | 香蕉国产人午夜视频在线观看 | 天天操综合视频 | 久久福利影院 | 国产高清不卡一区二区 | 久久99精品国产麻豆不卡 | 久久99久久99精品免观看不卡 | 国内精品久久久久影院亚洲 | 国产精品视频一区二区猎奇 | 四虎永久在线精品国产馆v视影院 | 日本高清中文字幕一区二区三区 | 四虎国产精品永久在线网址 | 老司机日日摸夜夜摸精品影院 | 日本欧美中文字幕 | 日韩在线视频中文字幕 | 天天操天天插天天射 | 好吊妞视频一区二区 | 亚洲a成人7777777久久 | 日本a视频在线 | 92国产福利久久青青草原 | 伊人色综合久久 | 国产午夜精品一区二区 |