服务器端编程(Servlet技术)
707.HTTP全称是什么? 有什么作用?
708.HTTP协议是无状态的协议是什么意思?请说明
709.HTTP1.1支持持续连接(也成长连接)吗?怎么理解持续连接?
710.HTTP watcher、firebug软件有什么作用
711.HTTP请求的基本格式是? 响应的基本格式是? 举例说明。
712.HTTP请求头中:Connection、refer、content-type,content-lengh代表什么含义
713.使用HTTP协议内容,说明get和post方式的区别
714.说出响应状态码:200,404,500的含义
715.B/S和C/S架构各自的优势和劣势?
716.Tomcat下载后,解压即可以使用。如果环境变量没有JAVA_HOME可以吗?
717.web项目建立后,会有目录:WEBROOT/Web_INF,他的核心作用是?
718.我们在src下面写的Java程序编程后的class文件会被放到项目的什么地方?
719.Tomcat目录:bin、lib、conf、webapps、work分别有什么作用?
720.如何手工发布一个web项目到Tomcat服务器上?
721.如何启动Tomcat服务器?如何终止?
722.Servlet只是一个普通的Java类,它继承了什么类就变成了servlet?
723.Servlet运行在哪里?脱离服务器可以独立运行吗?
724.serlvet类在服务器上通过<servlet>元素配置后,为什么还需要<servlet-mapping>?
725.一个servlet可以对应多个url吗?反过来讲,一个url可以对用多个servlet吗?
726.客户端发送请求到服务器,服务器再根据web.xml的配置调用相应的servlet程
序。这句话对吗?
727.servlet程序通过HttpServletResponse对象直接将信息发送给客户端。这句话对
吗?为什么?
728.一个web.xml文件可以配置多个servlet吗?
729.HttpServletRequest对象里面包含了什么信息?该对象是由谁生成的?
730.HttpServletResponse对象里面包含了什么信息?该对象是由谁生成的?
731.【上机】Tomcat服务器配置和使用
解压Tomcat,配置JAVA_HOME。启动Tomcat,关闭Tomcat。
732.【上机】建立一个web项目,建立一个servlet并配置,将该项目发布到Tomcat
下。然后访问你写好的servlet
733.【上机】建立第二个servlet,使用HttpServletRequest对象读取某个请求头信
息,使用HttpServletResponse对象向客户端写比较复杂的HTML/CSS/JS代码。
734.【上机】在myecipse集成自己的Tomcat
735.【上机】myeclipse中,server视图如何打开?
736.Tomcat服务器的server.xml中,我们修改哪个元素的哪个属性可以将服务器监听
端口改成其他端口?80端口有什么特别吗?
737.下面的url-pattern配置模式哪些是不对的:
<url-pattern>/111</url-pattern>
<url-pattern>/999</url-pattern>
<url-pattern>/oneoneone</url-pattern>
<url-pattern>/ttt/*</url-pattern>
<url-pattern>*.do</url-pattern>
<url-pattern>/sss/*.cc</url-pattern>
738.下面的Tomcat启动异常,如何解决:
严重: End event threw exception
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.IntrospectionUtils.callMethodN(IntrospectionUtils.java:959)
at org.apache.catalina.startup.CallMethodMultiRule.end(WebRuleSet.java:789)
at org.apache.tomcat.util.digester.Rule.end(Rule.java:229)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1138)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1774)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2930)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1642)
at org.apache.catalina.startup.ContextConfig.applicationWebConfig(ContextConfig.java:365)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1076)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:261)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4611)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> /sss/*.cc in servlet mapping
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:2742)
at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:2718)
... 37 more
2011-2-1 1:46:19 org.apache.catalina.startup.ContextConfig applicationWebConfig
739.下面的Tomcat启动异常如何解决:
严重: Error initializing endpoint
java.net.BindException: Address already in use: JVM_Bind <null>:80
at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:549)
at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:176)
at org.apache.catalina.connector.Connector.initialize(Connector.java:1022)
at org.apache.catalina.core.StandardService.initialize(StandardService.java:703)
at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:838)
at org.apache.catalina.startup.Catalina.load(Catalina.java:538)
at org.apache.catalina.startup.Catalina.load(Catalina.java:562)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:261)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.net.BindException: Address already in use: JVM_Bind
740.在servlet容器中,一个servlet类只会new一个servlet对象,这种说法对吗?
为什么?
741.关于servlet加载和初始化的时机问题,如下的说法对吗?
a. 如果使用<load-on-startup>,则servlet会在启动时加载。
b. 如果没有使用 <load-on-startup>,则servlet会在第一次被访问的时候加载。
742.请说明:service,doGet,doPost方法的调用顺序
743.405错误是如何报出来的,如何解决?
405 http method post is not supported by this url
744.当服务器收到一个请求时,会new一个新的线程来处理该请求。对吗?
745.Servlet中可以随意定义成员变量和随意使用它。对不对?为什么?
746.Tomcat配置文件web.xml中,DefalutServlet的作用是? JspServlet的作用是?
747.Tomcat服务器启动后,在项目下有一个a.jsp文件。然后,客户端访问:a.jsp。
那么,是直接访问a.jsp文件还是执行JspServlet?为什么?
748.welcome-flie-list元素有什么作用?
749.翻译下面的英文:
<!-- ==================== Default Welcome File List ===================== -->
<!-- When a request URI refers to a directory, the default servlet looks -->
<!-- for a "welcome file" within that directory and, if present, -->
<!-- to the corresponding resource URI for display. If no welcome file -->
<!-- is present, the default servlet either serves a directory listing, -->
<!-- or returns a 404 status, depending on how it is configured. -->
<!-- -->
<!-- If you define welcome files in your own application's web.xml -->
<!-- deployment descriptor, that list *replaces* the list configured -->
<!-- here, so be sure that you include any of the default values that -->
<!-- you wish to include. -->
750.如何清除掉浏览器端的缓存?
751.服务器端遇到修改了代码不起作用。如何彻底干净的解决这个问题?
752.HttpServletRequest是一个类还是接口?他的作用是?
753.如下英文是说明HttpServletRequest的作用的,请翻译之。
Defines an object to provide client request information to a servlet. The servlet container creates a ServletRequest object and passes it as an argument to the servlet's service method.
A ServletRequest object provides data including parameter name and values, attributes, and an input stream. Interfaces that extend ServletRequest can provide additional protocol-specific data (for example, HTTP data is provided by HttpServletRequest.
HttpServletRequest Extends the ServletRequest interface to provide request information for HTTP servlets.
The servlet container creates an HttpServletRequest object and passes it as an argument to the servlet's service methods (doGet, doPost, etc).
754.HttpServletRequest中,获取客户端IP的API是?
755.【上机】用代码读取客户端请求头信息,打印成如下格式:
content-type:application/x-www-form-urlencoded
accept-encoding:gzip, deflate
user-agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.2)
host:localhost
connection:Keep-Alive
cache-control:no-cache
756.通过getParameter方法可以获得get方式请求的参数?那么能不能获取post方式请求的参数?
757.多个同名不同值的参数(比如:复选框使用时)传递给服务器,服务器端使用哪个API处理?
758.【上机】 完成课堂上关于Request的测试代码
759.HttpServletReponse是一个接口还是类?他的作用是?
760.翻译如下英文,明白HttpServletResponse对象的作用:
Defines an object to assist a servlet in sending a response to the client. The servlet container creates a ServletResponse object and passes it as an argument to the servlet's service method.
To send binary data in a MIME body response, use the ServletOutputStream returned by getOutputStream(). To send character data, use the PrintWriter object returned by getWriter(). To mix binary and text data, for example, to create a multipart response, use a ServletOutputStream and manage the character sections manually.
The charset for the MIME body response can be specified explicitly using the setCharacterEncoding(java.lang.String) and setContentType(java.lang.String) methods, or implicitly using the setLocale(java.util.Locale) method. Explicit specifications take precedence over implicit specifications. If no charset is specified, ISO-8859-1 will be used. The setCharacterEncoding, setContentType, or setLocale method must be called before getWriter and before committing the response for the character encoding to be used.
761.下面代码有什么问题,请指出:
resp.setContentType("text/html,charset=utf-8");
762.【上机】利用绘图工具来解释请求转发和重定向有什么区别,再用文字总结两者有
什么不同?
763.request作为作用域在属于同一个请求的servlet之间共享!它的内部机制是什么?
764.request方法中,setAttribute,getAttribute,removeAttrbiute实质上是内部有一
个Map对象来维持映射关系。对吗?
765."/"的问题。在浏览器发请求时它代表什么含义?服务器内部跳转时代表什么含义?
766.【上机】 完成课堂上关于Response的测试代码,以及请求转发和重定向的代码
一次会话指的是什么?
767.会话建立后,立马就创建session对象吗?
768.request.getSession(),调用两次后,返回的Session对象,是同一个对象还是不
同的两个对象,为什么?
769.在servlet1中通过session.setAttribute("a","aaa")放了a属性,一定能在
servlet2中得到吗?请详细解释原因。
770.服务器中会有很多个session对象,那么是通过什么确定客户端跟session对象的
对应关系的?请说明。
771.我想让session对象使用完后,立马失效。可以调用哪些方法?
772.翻译如下英文,明白session的基本用法:
Provides a way to identify a user across more than one page request or visit to a Web site and to store information about that user.
The servlet container uses this interface to create a session between an HTTP client and an HTTP server. The session persists for a specified time period, across more than one connection or page request from the user. A session usually corresponds to one user, who may visit a site many times. The server can maintain a session in many ways such as using cookies or rewriting URLs.
This interface allows servlets to
View and manipulate information about a session, such as the session identifier, creation time, and last accessed time
Bind objects to sessions, allowing user information to persist across multiple user connections
773.【上机】 完成课堂上关于Session的测试代码
774.Cookie技术是一种在客户端保存HTTP状态的技术。对吗?
775.翻译如下英文,搞清楚Cookie到底是做什么的:
Creates a cookie, a small amount of information sent by a servlet to a Web browser, saved by the browser, and later sent back to the server. A cookie's value can uniquely identify a client, so cookies are commonly used for session management.
A cookie has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number. Some Web browsers have bugs in how they handle the optional attributes, so use them sparingly to improve the interoperability of your servlets.
The servlet sends cookies to the browser by using the HttpServletResponse.addCookie(javax.servlet.http.Cookie) method, which adds fields to HTTP response headers to send cookies to the browser, one at a time. The browser is expected to support 20 cookies for each Web server, 300 cookies total, and may limit cookie size to 4 KB each.
The browser returns cookies to the servlet by adding fields to HTTP request headers. Cookies can be retrieved from a request by using the HttpServletRequest.getCookies() method. Several cookies might have the same name but different path attributes.
776.【上机】 向客户端写一个Cookie:loginname=zhangsan,并在客户端保存
两周时间。
777.如果我们没有设置Cookie的Max Age属性,那么这个Cookie会不会写到客户
端硬盘上?浏览器重启后,这个Cookie还能不能读取到?
778.读取Cookie,实际上是直接读取客户端机器上的文本文件。对吗? 给出理由。
779.【上机】在服务器端使用什么api可以获取cookie的值,请用代码实现。
780.如何在Servlet中获取相应的ServletConfig对象?
781.获取到ServletConfig对象后,通过该对象只能读取对应Servlet的配置信息吗?
782.ServletConfig对象中,通过哪个方法获取<init-param>参数信息?
783.ServletContext如何加载<context-param>参数。他能不能读取某个Servlet下
面的<init-param>参数?
784.说出这三个作用域(request,session,servletContext)的生命周期及作用范围
785.翻译下面的英文,明白ServletContext的用法:
Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file.
There is one context per "web application" per Java Virtual Machine. (A "web application" is a collection of servlets and content installed under a specific subset of the server's URL namespace such as /catalog and possibly installed via a .war file.)
In the case of a web application marked "distributed" in its deployment descriptor, there will be one context instance for each virtual machine. In this situation, the context cannot be used as a location to share global information (because the information won't be truly global). Use an external resource like a database instead.
The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized.
786.【上机】完成测试ServletConfig、ServletContext的课堂代码
787.【上机】完成登录流程练习
788.【上机】如何配置虚拟路径,实现将电脑某个图片目录映射成网络可访问的目录