请教几个JSP问题,等着救命,谢谢

zapdos 2007-03-14 11:55:19
1:在访问几次连接池后,出现资源不足,应该怎么解决?调用哪个方法来释放资源呢?

2:在MVC的模式中,是通过Controller来访问Viewer的,那么,出了使用Filter之外,怎么禁止别人直接访问Viewer呢?

3:我在使用Filter时,只要一配置web.xml,就出现无法访问所有页面的情况,是什么原因呢?源码:
在web.xml的web-app里加入了:
<filter>
<filter-name>servfilter</filter-name>
<filter-class>test.servfilter</filter-class>
</filter>
<filter-mapping>
<filter-name>servfilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Filter:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class BaseFilter extends HttpServlet implements Filter {
private FilterConfig filterConfig;
public void init(FilterConfig filterConfig) {
this.filterConfig = filterConfig;
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) {
try {
request.setCharacterEncoding("GB2312");
filterChain.doFilter(request,response);
} catch(ServletException sx) {
filterConfig.getServletContext().log(sx.getMessage());
}
catch(IOException iox) {
filterConfig.getServletContext().log(iox.getMessage());
}
}
public void destroy() {
}
}

求哪位高手帮帮忙,真的是等救命的,我只有70分了,全部送上,不够的话我再想办法散分,谢谢
...全文
182 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
zapdos 2007-03-14
  • 打赏
  • 举报
回复
那个test.servfilter是test.BaseFilter
Filter类也package test;了
这里一时写错了,总之,路径是对的
zapdos 2007-03-14
  • 打赏
  • 举报
回复
终于解决了,原来是打包错了,以后要细心一点才行
谢谢各位的帮助,散分了
zapdos 2007-03-14
  • 打赏
  • 举报
回复
listener解决了,原来是listener漏了个i
现在Filter还是搞不定,认真检查过了,找不出错,救命啊
zapdos 2007-03-14
  • 打赏
  • 举报
回复
啊,我要死了,就是卡在filter这里了,以前都用得好好的忽然之间用不了了,死活都搞不掂,
只要一配置web.xml就出错,怎么办啊,哪位高手有过类似的经历啊?
listener也是这个情况
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>

<listener>
<listener-class>
SessionCount.SessionCounter
</lstener-class>
</lstener>

<servlet>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<servlet-class>org.apache.jsp.index_jsp</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<url-pattern>/index.jsp</url-pattern>
</servlet-mapping>

</web-app>


错误:
HTTP Status 404 - /

--------------------------------------------------------------------------------

type Status report

message /

description The requested resource (/) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.5.13
yxwonline 2007-03-14
  • 打赏
  • 举报
回复
<url-pattern>/*</url-pattern>
设置了 在/下面所有页面都将被过滤!
Sunny319 2007-03-14
  • 打赏
  • 举报
回复
1.数据库使用连接池,每次使用完连接及时colse.
2.Controller是用来控制Viewer之间怎么跳转的.Filter其实就可以满足要求了,当然你也可以在Controller里面来控制.
3.看你的配置是对的.你debug一下看看具体原因.

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧