|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
Java的B/s开发是通常是javaweb开发,又叫J2EE开发,J2SE是手机开发。C#的C/s和B/s开发是说.net和Asp开发。。u在这里说明一点;资深一点的Java和C#程序员都明白一点 HttpServlet是从GenericServlet承继而来,因而它具有GenericServlet相似的办法和对象,是我们利用Servlet编程常常用到的包,它撑持HTTP的post和get等办法。
编程思绪:上面的例子,运转了局是输入复杂地前往客户发送给服务器的哀求行和头部信息,和一些可会见的HTTP信息等。
SnoopServlet.java的源代码以下:
importjava.io.IOException;
importjava.io.PrintWriter;
importjava.util.Enumeration;
importjavax.servlet.*;
importjavax.servlet.http.*;
publicclassSnoopServletextendsHttpServlet{
publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)
throwsServletException,IOException
{
PrintWriterout=response.getWriter();
response.setContentType("text/plain");
out.println("SnoopServlet");
out.println();
out.println("Servletinitparameters:");
Enumeratione=getInitParameterNames();
while(e.hasMoreElements()){
Stringkey=(String)e.nextElement();
Stringvalue=getInitParameter(key);
out.println(""+key+"="+value);
}
out.println();
out.println("Contextinitparameters:");
ServletContextcontext=getServletContext();
Enumerationenum=context.getInitParameterNames();
while(enum.hasMoreElements()){
Stringkey=(String)enum.nextElement();
Objectvalue=context.getInitParameter(key);
out.println(""+key+"="+value);
}
out.println();
out.println("Contextattributes:");
enum=context.getAttributeNames();
while(enum.hasMoreElements()){
Stringkey=(String)enum.nextElement();
Objectvalue=context.getAttribute(key);
out.println(""+key+"="+value);
}
out.println();
out.println("Requestattributes:");
e=request.getAttributeNames();
while(e.hasMoreElements()){
Stringkey=(String)e.nextElement();
Objectvalue=request.getAttribute(key);
out.println(""+key+"="+value);
}
out.println();
out.println("ServletName:"+getServletName());
out.println("Protocol:"+request.getProtocol());
out.println("Scheme:"+request.getScheme());
out.println("ServerName:"+request.getServerName());
out.println("ServerPort:"+request.getServerPort());
out.println("ServerInfo:"+context.getServerInfo());
out.println("RemoteAddr:"+request.getRemoteAddr());
out.println("RemoteHost:"+request.getRemoteHost());
out.println("CharacterEncoding:"+request.getCharacterEncoding());
out.println("ContentLength:"+request.getContentLength());
out.println("ContentType:"+request.getContentType());
out.println("Locale:"+request.getLocale());
out.println("DefaultResponseBuffer:"+response.getBufferSize());
out.println();
out.println("Parameternamesinthisrequest:");
e=request.getParameterNames();
while(e.hasMoreElements()){
Stringkey=(String)e.nextElement();
String[]values=request.getParameterValues(key);
out.print(""+key+"=");
for(inti=0;i<values.length;i++){
out.print(values[i]+"");
}
out.println();
}
out.println();
out.println("Headersinthisrequest:");
e=request.getHeaderNames();
while(e.hasMoreElements()){
Stringkey=(String)e.nextElement();
Stringvalue=request.getHeader(key);
out.println(""+key+":"+value);
}
out.println();
out.println("Cookiesinthisrequest:");
Cookie[]cookies=request.getCookies();
if(cookies!=null){
for(inti=0;i<cookies.length;i++){
Cookiecookie=cookies[i];
out.println(""+cookie.getName()+"="+cookie.getValue());
}
}
out.println();
out.println("RequestIsSecure:"+request.isSecure());
out.println("AuthType:"+request.getAuthType());
out.println("HTTPMethod:"+request.getMethod());
out.println("RemoteUser:"+request.getRemoteUser());
out.println("RequestURI:"+request.getRequestURI());
out.println("ContextPath:"+request.getContextPath());
out.println("ServletPath:"+request.getServletPath());
out.println("PathInfo:"+request.getPathInfo());
out.println("PathTrans:"+request.getPathTranslated());
out.println("QueryString:"+request.getQueryString());
out.println();
HttpSessionsession=request.getSession();
out.println("RequestedSessionId:"+
request.getRequestedSessionId());
out.println("CurrentSessionId:"+session.getId());
out.println("SessionCreatedTime:"+session.getCreationTime());
out.println("SessionLastAccessedTime:"+session.getLastAccessedTime());
out.println("SessionMaxInactiveIntervalSeconds:"+session.getMaxInactiveInterval());
out.println();
out.println("Sessionvalues:");
Enumerationnames=session.getAttributeNames();
while(names.hasMoreElements()){
Stringname=(String)names.nextElement();
out.println(""+name+"="+session.getAttribute(name));
}
}
} 编程技能申明:
其实产生见解的过程就是训练自己发现问题,分析问题的能力。根据以上的认识我想谈下传统的学习与通过视频独立学习的优缺点: |
|