}
return tempstr; }
11.servlet执行时一般实现哪几个方法? 答:
public void init(servletconfig config) public servletconfig getservletconfig() public string getservletinfo()
public void service(servletrequest request,servletresponse response)
public void destroy()
12.说出数据连接池的工作机制是什么?
答:j2ee服务器启动时会建立一定数量的池连接,并一直维持不少于此数目的池连接。客户端程序需要连接时,池驱动程序会返回一个未使用的池连接并将其表记为忙。如果当前没有空闲连接,池驱动程序就新建一定数量的连接,新建连接的数量有配置参数决定。当使用的池连接调用完成后,池驱动程序将此连接表记为空闲,其他调用就可以使用这个连接。
13.class.forname的作用?为什么要用?
答:调用该访问返回一个以字符串指定类名的类的对象。 1、如何混合使用jsp和ssi #include? 在jsp中可以使用如下方式包含纯html: !--#i nclude file=data.inc--
但是如果data.inc中包含jsp code ,我们可以使用: %@include file=data.inc%
2、如何执行一个线程安全的jsp? 只需增加如下指令
%@ page isthreadsafe=false %
3、jsp如何处理html form中的数据? 通过内置的request对象即可,如下: %
string item = request.getparameter(item); int howmany = new
integer(request.getparameter(units)).intvalue(); % 4、在jsp如何包含一个静态文件?
静态包含如下:%@ include file=copyright.html %
动态包含如下:jsp:include page=copyright.html flush=true/
5、在jsp中如何使用注释? 主要有四中方法: 1。%-- 与 --% 2。//
3。/**与**/ 4。!--与--
6、在jsp中如何执行浏览重定向? 使用如下方式即可: %
response.setstatus(httpservletresponse.sc_moved_permanently); string newlocn=/newpath/index.html; response.setheader(location,newlocn); %
7、如何防止在jsp或servlet中的输出不被browser保存在cache中?
把如下脚本加入到jsp文件的开始即可: %
response.setheader(cache-control,no-store); //http 1.1 response.setheader(pragma,no-cache); //http 1.0
response.setdateheader (expires, 0); //prevents caching at the proxy server %
8、在jsp中如何设置cookie?
cookie是作为http header的一部分被发送的,如下方法即可设置: %
cookie mycookie = new cookie(aname,avalue); response.addcookie(mycookie);
相关推荐: