Javaweb background to distinguish between mobile phone or computer login

Source: Internet
Author: User
Tags blank page

This project needs to go to the user's device to jump page, I put the home page in a blank page, let this blank page automatically submit the form, in the background action will invoke the tool class tool class code:package com.util;import  Description information unique to Javax.servlet.http.httpservletrequest;public class gethttp {/** wap gateway via header information  * /private static string mobilegatewayheaders[] = new string[] {  "ZXWAP" ,//  ZTE provides Via information for WAP gateways, such as: Via=zxwap// gatewayzte// technologies, "chinamobile.com",//  China Mobile's Nokia WAP Gateway, such as:via=wtp/1.1// gdsz-pb-gw003-wap07.gd.chinamobile.com  (Nokia// wap gateway  4.1 cd1/ecd13_d/4.1.04) "monternet.com",//  the gateway to the mobile dream network, such as:via=wtp/1.1//  bjbj-ps-wap1-gw08.bj1.monternet.com.  (nokia wap// gateway 4.1 cd1/ecd13_e/4.1.05) " Infox ",//  the WAP gateways provided by Huawei, such as:via=http/1.1 gdgz-ps-gw011-wap2  (infox-wisg// huawei  Technologies), or via=infox wap gateway v300r001// huawei technologies "XMS  724SOLUTIONS&NBSP;HTG ",//  foreign telecom operators of WAP Gateway, do not know which one" Wap.lizongbo.com "Bytemobile",//  the head information that is simulated when testing itself,//  seems to be a solution to mobile internet to improve the efficiency of network operation, for example: via=1.1 bytemobile osn//  WebProxy/5.1};/**  user-agent keywords  */private static String[]  for IE or Firefox browser on your computer pcheaders = new string[] {  "windows 98", "Windows me",  "Windows  ", " Windows xp ", " windows nt ", " Ubuntu " };/**  Mobile browser user-agent keywords  */private static String[] mobileUserAgents = new String[] {  " Nokia ",// , there are Shanzhai machine also write this, is also a mobile phone,mozilla/5.0//  (nokia5800// xpressmusic) Uc// applewebkit ( Like// gecko)// safari/530 "Samsung",//  Samsung phone// samsung-gt-b7722/1.0+shp/vpp/r5+dolfin/1.5+ nextreaming+smm-mms/1.2.0+profile/midp-2.1+configuration/cldc-1.1 "MIDP-2",// j2me2.0,mozilla/5.0  ( symbianos/9.3; u; series60/3.2// nokiae75-1 /110.48.125 profile/midp-2.1//  configuration/cldc-1.1 ) &nbsP applewebkit/413  (Khtml like// gecko)  safari/413 "CLDC1.1",//&NBSP;M600/MIDP2.0/CLDC1.1/ screen-240x320 "SymbianOS",//  Saipan system, "MAUI",//&NBSP;MTK Cottage default ua "untrusted/1.0",//  suspected copycat UA, basic can be determined or mobile " Windows ce ",// windows ce,mozilla/4.0  (compatible; msie 6.0;// windows  ce; iemobile 7.11) "IPhone",// iphone also turn WAP? Whatever it is, differentiate it first. mozilla/5.0  (iphone; u; cpu// iphone os 4_1 like mac os x; &NBSP;ZH-CN)  AppleWebKit/532.9//  (Khtml like gecko)  mobile/8b117 "IPad",//  IPad's ua,mozilla/5.0  (ipad; u; cpu os 3_2 like mac os x;//  ZH-CN)  AppleWebKit/531.21.10  (Khtml like gecko)// version/4.0.4 mobile/7b367  safari/531.21.10 "Android",// android also turn WAP? mozilla/5.0  (linux; u; android// 2.1-update1; zh-cn; xt800 build/tita_m2_ 16.22.7)//&NBsp applewebkit/530.17  (Khtml like gecko)  version/4.0// mobile safari/530.17 " BlackBerry ",// blackberry8310/2.7.0.106-4.5.0.182" UCWEB ",// ucweb only give WAP page?  nokia5800// xpressmusic/ucweb7.5.0.66/50/999 "UCWeb",//  lowercase ucweb appears to be a proxy server for UC mozilla/6.0  ( compatible; msie 6.0;)// opera ucweb-squid "BREW",//  very strange UA, for example: rew-applet/0x20068888   (BREW/3.1.5.20;&NBSP;DEVICEID://&NBSP;40105;&NBSP;LANG:&NBSP;ZHCN)  ucweb-squid "J2ME",//  very weird UA , only J2ME four letters "Yulong",//  yulong phone, yulong-coolpadn68/10.14 ipanel/2.0 ctc/1.0 "Yulong",//  or Yu-long " Coolpad ",//  Yulong Cool faction yl-coolpads100/08.10.s100 polaris/2.9 ctc/1.0" Tianyu ",//  Tian language mobile phone Tianyu-ktouch /v209/midp2.0/cldc1.1/screen-240x320 "ty-",//  Tian, ty-f6229/701116_6215_v0230 jupitor/2.2 ctc/1.0 " K-touch ",//  or heavenly language k-touch_n2200_cmcc/tbg110022_1223_v0801 mtk/6223// release/30.07.2008  browser/wap2.0 "Haier",//  Haier mobile phone, haier-hg-m217_cmcc/3.0 release/12.1.2007// browser/wap2.0 "Dopod",//  Phone "Lenovo",//  Lenovo mobile phone, Lenovo-P650WG/ s100 lmp/lml release/2010.02.22// profile/midp2.0 configuration/cldc1.1 "LENOVO",//  Lenovo mobile phone, such as: lenovo-p780/176a "Huaqin",//  China Qin mobile phone "aigo-",//  Patriot actually also out of the cell phone, aigo-800c/2.04 tmss-browser/1.0.0  ctc/1.0 "ctc/1.0",//  meaning Unknown "ctc/2.0",//  meaning Unknown "CMCC",//  Mobile Custom mobile phone, k-touch_n2200_cmcc/tbg110022_ 1223_v0801 mtk/6223// release/30.07.2008 browser/wap2.0 "Daxian",//  big display mobile phone daxian x180  up. browser/6.2.3.2 (GUI)  mmp/2.0 "mot-",//  Motorola, mot-motorokre6/1.0 linuxos/2.4.20 release/ 8.4.2006// browser/opera8.00 profile/midp2.0 configuration/cldc1.1// software/r533_g_ 11.10.54R "SonyEricsson",//  sony Ericsson Mobile,sonyericssonp990i/r100 mozilla/4.0//  (Compatible; msie  6.0; symbian os; 405) &NBSP;OPERA//&NBSP;8.65&NBSP;[ZH-CN] "GIONEE",//  Phone "HTC",// &NBSP;HTC mobile Phone "ZTE",// ZTE Mobile, Zte-a211/p109a2v1.0.0/wap2.0 profile "Huawei",// , "WebOS",// palm Mobile,mozilla/5.0  ( WEBOS/1.4.5;&NBSP;U;&NBSP;ZH-CN)// applewebkit/532.2  (Khtml like gecko)  Version/1.0//  safari/532.2 pre/1.0 "Gobrowser",// 3g gobrowser.user-agent=nokia5230/gobrowser/2.0.290//  safari "Iemobile",// windows ce mobile phone with browser, "WAP2.0"//  support wap 2.0};/** *  According to the characteristics of the current request, determine whether the request is from the phone terminal, the main detection of special header information, and user-agent this header *  *  @param  request *             http Request  *  @return   If a phone signature rule is hit, the corresponding feature string  */public static boolean ismobiledevice (httpservletrequest  Request)  {boolean b = false;boolean pcflag = false;boolean mobileflag  = false; String via = request.getheader ("via"); System.out.println (VIA); String useragent = request.getheAder ("User-agent"); System.out.println (useragent);for  (int i = 0; via != null &&  !via.trim (). Equals ("") && i < mobilegatewayheaders.length; i++)  {if   (Via.contains (mobilegatewayheaders[i))  {mobileflag = true;break;}} for  (int i = 0; !mobileflag && useragent != null& & !useragent.trim (). Equals ("")  && i < mobileuseragents.length; i+ +)  {if  (Useragent.contains (mobileuseragents[i))  {mobileflag = true;break;}} for  (Int i = 0; useragent != null && !useragent.trim (). Equals ("") && i < pcheaders.length; i++)  {if  (Useragent.contains ( Pcheaders[i])  {pcflag = true;break;}} if  (Mobileflag == true && pcflag == false)  {b&Nbsp;= true;} Return b;// false pc true shouji}} and in the action call, I did this: httpservletrequest request  = servletactioncontext.getrequest (); Boolean b = gethttp.ismobiledevice (Request); System.out.println ("this device type is: "  + b+  "   (true is  means telephone, other means pc or pad);if  (B.equals (true))  { return  "MOBISUCC";}  elsereturn  "PCSUCC";}


Javaweb background to distinguish between mobile phone or computer login

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.