|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
什么时候上述的三种开发工具能和三为一,什么时候java的竞争力才更强,才有机会拉拢更多的程序员投入到对java的开发上,因为到时的开发工具将会比.net的更简单。还有一点也很关键,什么时候java推出的jsf能成为真正意义上的标准。js|搜刮引擎
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
//werejustpassingthisontoanotherserver,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;
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);
}
}
java比较简单,没有C++的烦琐,但学习时最好有C++为基础.与JSP和SQL起应用,功能强大. |
|