|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
什么时候上述的三种开发工具能和三为一,什么时候java的竞争力才更强,才有机会拉拢更多的程序员投入到对java的开发上,因为到时的开发工具将会比.net的更简单。还有一点也很关键,什么时候java推出的jsf能成为真正意义上的标准。js|显现packagehall;
importJava.io.*;
importjavax.servlet.*;
importjavax.servlet.http.*;
importjava.net.*;
importjava.util.*;
publicclassShowSessionextendsHttpServlet{
publicvoiddoGet(HttpServletRequestrequest,
HttpServletResponseresponse)
throwsServletException,IOException{
HttpSessionsession=request.getSession(true);
response.setContentType("text/html");
PrintWriterout=response.getWriter();
Stringtitle="SearchingtheWeb";
Stringheading;
IntegeraccessCount=newInteger(0);;
if(session.isNew()){
heading="Welcome,Newcomer";
}else{
heading="WelcomeBack";
IntegeroldAccessCount=
//在ServletAPI2.2中利用getAttribute而不是getValue
(Integer)session.getValue("accessCount");
if(oldAccessCount!=null){
accessCount=
newInteger(oldAccessCount.intValue()+1);
}
}
//在ServletAPI2.2中利用putAttribute
session.putValue("accessCount",accessCount);
out.println(ServletUtilities.headWithTitle(title)+
"<BODYBGCOLOR=\"#FDF5E6\">\n"+
"<H1ALIGN=\"CENTER\">"+heading+"</H1>\n"+
"<H2>InformationonYourSession:</H2>\n"+
"<TABLEBORDER=1ALIGN=CENTER>\n"+
"<TRBGCOLOR=\"#FFAD00\">\n"+
"<TH>InfoType<TH>Value\n"+
"<TR>\n"+
"<TD>ID\n"+
"<TD>"+session.getId()+"\n"+
"<TR>\n"+
"<TD>CreationTime\n"+
"<TD>"+newDate(session.getCreationTime())+"\n"+
"<TR>\n"+
"<TD>TimeofLastAccess\n"+
"<TD>"+newDate(session.getLastAccessedTime())+"\n"+
"<TR>\n"+
"<TD>NumberofPreviousAccesses\n"+
"<TD>"+accessCount+"\n"+
"</TABLE>\n"+
"</BODY></HTML>");
}
publicvoiddoPost(HttpServletRequestrequest,
HttpServletResponseresponse)
throwsServletException,IOException{
doGet(request,response);
}
}
令人可喜的是java现在已经开源了,所以我想我上述的想法也许有一天会实现,因为java一直都是不断创新的语言,每次创新都会给我们惊喜,这也是我喜欢java的一个原因。 |
|