HashMap.keySet()

时间:2017-11-14 14:34:58

标签: java database tomcat concurrenthashmap

我有一个非常讨厌的问题。

我开发了一个带有JSP的网站,当我在Netbeans上运行时,一切都在我的本地PC上完美运行。

但是如果我把它放在我的Tomcat 7服务器上,那么一行页面会在hsFilter.keySet()行中获得Null Pointer Exception:

ConcurrentHashMap<String, LinkedList<String>> hsFilter = (ConcurrentHashMap<String, LinkedList<String>>) session.getAttribute("hashMap_typ");
Set<String> set = hsFilter.keySet();
Iterator it = set.iterator();

Tomcat日志说明如下:

  

java.lang.NullPointerException at   org.apache.jsp.jsp.dynamisch_005fmitglieder_jsp._jspService(dynamisch_005fmitglieder_jsp.java:947)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:728)at   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)     在   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)     在org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)     在javax.servlet.http.HttpServlet.service(HttpServlet.java:728)at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)     在   org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)     在   org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)     在   org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)     在   org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)     在Servlet.MainServlet.doPost(MainServlet.java:137)处   javax.servlet.http.HttpServlet.service(HttpServlet.java:647)at at   javax.servlet.http.HttpServlet.service(HttpServlet.java:728)at at   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)     在   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)     在   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)     在   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)     在   org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)     在   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)     在   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)     在   org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)     在   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)     在   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)     在   org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)     在   org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:589)     在   org.apache.tomcat.util.net.AprEndpoint $ SocketProcessor.run(AprEndpoint.java:1852)     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)     at java.util.concurrent.ThreadPoolExecutor $ Worker.run(Unknown Source)     在java.lang.Thread.run(未知来源)

真正疯狂的是页面被中途加载并在中间中断。 如果我以管理员身份登录,一切正常,但如果我以用户身份登录,则会获得NPE。

我希望有人可以帮助我,因为我是JSP的新手。

迎接

0 个答案:

没有答案