java搜索引擎

你来自何处并不重要,重要的是你要去往何方,人生最重要的不是所站的位置,而是所去的方向。人只要不失去方向,就永远不会失去自己!
packagecoreservlets;importjava.io.*;importjavax.servlet.*;importjavax.servlet.http.*;importjava.net.*;publicclassSearchEnginesextendsHttpServlet{publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{StringsearchString=request.getParameter("searchString");if((searchString==null)(searchString.length()==0)){reportProblem(response,"Missingsearchstring.");return;}//TheURLEncoderchangesspacesto"+"signsandother//non-alphanumericcharactersto"%XY",whereXYisthe//hexvalueoftheASCII(orISOLatin-1)character.//BrowsersalwaysURL-encodeformvalues,sothe//getParametermethoddecodesautomatically.Butsince//we"rejustpassingthisontoanotherserver,weneedto//re-encodeit.searchString=URLEncoder.encode(searchString);StringnumResults=request.getParameter("numResults");if((numResults==null)(numResults.equals("0"))(numResults.length()==0)){numResults="10";}StringsearchEngine=request.getParameter("searchEngine");if(searchEngine==null){reportProblem(response,"Missingsearchenginename.");return;}SearchSpec[]commonSpecs=SearchSpec.getCommonSpecs();for(inti=0;i<commonSpecs.length;i++){SearchSpecsearchSpec=commonSpecs[i];if(searchSpec.getName().equals(searchEngine)){Stringurl=searchSpec.makeURL(searchString,numResults);response.sendRedirect(url);return;}}reportProblem(response,"Unrecognizedsearchengine.");}privatevoidreportProblem(HttpServletResponseresponse,Stringmessage)throwsIOException{response.sendError(response.SC_NOT_FOUND,"<H2>"+message+"</H2>");}publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{doGet(request,response);}}

本文javascriptp搜索引擎到此结束。成熟是一种明亮而不刺眼的光辉,一种圆润而不腻耳的音响,一种不需要对别人察颜观色的从容,一种终于停止了向周围申诉求告的大气,一种不理会哄闹的微笑,一种洗刷了偏激的淡漠,一种无须声张的厚实,一种并不陡峭的高度。小编再次感谢大家对我们的支持!

您可能有感兴趣的文章
Java 实例 - 字符串反转

Java实例--字符串替换

Java实例--删除字符串中最后一个字符

Java实例--查找字符串最后一次出现的位置

Java实例--字符串比较