tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 19103] New: - Exception thrown attempting to use session "removeAttribute()" method
Date Thu, 17 Apr 2003 07:10:00 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19103>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19103

Exception thrown attempting to use session "removeAttribute()" method

           Summary: Exception thrown attempting to use session
                    "removeAttribute()" method
           Product: Tomcat 4
           Version: 4.1.24
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Jasper
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: wagner@sprynet.com


The following code is (with the exception of me adding an import statement to
get it to compile) right out of a JSP book (I've put "---->" to point to the
code generating the error). I assume the author of the book knows more about
this than I do, thus I assume it's correct, but it COULD be dated.

Here's the code:


<%@ page import="java.util.Enumeration" %>
<HTML><HEAD><TITLE>Example of Using Session</TITLE></HEAD><BODY>
[<A HREF=toys.jsp>Shop for Toys</A>] 
<H1> Online CD Catalog </H1>
<TABLE>
<% 
   String[] titles = {"Tchaikovsky_Orchestral_Masterpieces",
                      "Mendelssohn_Melodic_Masterpieces",
                      "Haydn_Symphonic_Masterpieces",
                      "Schumann_Romantic_Legends",
                      "Bach_Baroque_Masterpieces"};
   for(int j=0; j<titles.length; j++){ %>
     <TR><TD><%=titles[j]%></TD>
         <TD><A HREF=cds.jsp?itemName=<%=titles[j]%>>
              Add to Shopping Cart</A></TD>
     </TR>
<% } %>
</TABLE>
<A HREF=cds.jsp?itemName=emptyCart>Empty Shopping Cart</A>
<% String item = request.getParameter("itemName");
   if(item != null && item.equals("emptyCart"))
      {
      Enumeration attributeNames = session.getAttributeNames();
      while(attributeNames.hasMoreElements())
         {
         String attributeName = (String)attributeNames.nextElement();
         System.out.println("WVW++++++++++attribute is: "+attributeName);
------>  session.removeAttribute(attributeName);
         }
      } 
   else if(item != null)
      {
       String attributeName = item + "CD";
       session.setAttribute(attributeName,item);
       }
%>
<HR>
<H1> Content of Shopping Cart </H1>
<UL>
<% Enumeration attributeNames = session.getAttributeNames();
   if(attributeNames != null)
   while(attributeNames.hasMoreElements()){
     String attributeName = (String)attributeNames.nextElement();
     String attributeValue = (String)session.getAttribute(attributeName); %>
     <LI><%=attributeValue%>
<% } %>
</BODY>
</HTML>

-----------------------
END OF SOURCE CODE!!!
-----------------------

This also links to another nearly identical page, so I haven't included it. The
page will generate a list of items that you can add to a "shopping cart". You
can also empty the shopping cart by clicking on the:

       <A HREF=cds.jsp?itemName=emptyCart>Empty Shopping Cart</A>

link. This will work fine if only one item has been put in the shopping cart,
but if more than one item is added, the following exception is generated in both
Mac OS X 10.2 and Red Hat Linux 7.2, using both 4.1.18 and 4.1.24:
 
HTTP Exception 500-
TYPE Exception report
MESSAGE
DESCRIPTION The server encountered an internal error () that prevented it from
fulfilling this request.
EXCEPTION
org.apache.jasper.JasperException
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
	at java.lang.Thread.run(Thread.java:536)

ROOT CAUSE

java.util.ConcurrentModificationException
	at java.util.HashMap$HashIterator.nextEntry(HashMap.java:762)
	at java.util.HashMap$KeyIterator.next(HashMap.java:798)
	at org.apache.catalina.util.Enumerator.nextElement(Enumerator.java:166)
	at org.apache.jsp.cds_jsp._jspService(cds_jsp.java:99)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
	at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
	at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
	at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
	at java.lang.Thread.run(Thread.java:536)

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message