10 Replies Latest reply: Nov 8, 2007 1:51 PM by 807600 RSS

    multiple calendar instances

    807600
      Hi, Can someone please help? I created a calendar instance :

      PTO currentPTO = (PTO)session.getAttribute("currentPTO");
           
      GregorianCalendar cal = new GregorianCalendar();
      cal.setTime(currentPTO.getEmploymentDate());

      This worked. Then I realized I needed a couple more different times to do time calculations, so I added these 2.
           
      GregorianCalendar todayCal = (GregorianCalendar) Calendar.getInstance();

      Calendar annivCal = new GregorianCalendar(todayCal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE));

      And still everything seemed to be fine. I could compile and run the program, but now when I try to do the math on the calendars, its going back and complaining about the cal.setTime line. I change it to the way the other 2 are written, but then it said the constructor wasn't right. What am I doing wrong?
        • 1. Re: multiple calendar instances
          807600
          What does it "complain" about regarding the setTime line? (post error/exception?)
          • 2. Re: multiple calendar instances
            807600
            When you say "complaining about the cal.setTime line," what is the error it's reporting?

            And what do you mean by "do the math on the calendars"?
            • 3. Re: multiple calendar instances
              807600
              The error says org.apache.jasper.JasperException: Exception in JSP: /web/ptoSheet.jsp:11. That's really all it says, and this is line 11:

              11: cal.setTime(currentPTO.getEmploymentDate());
              • 4. Re: multiple calendar instances
                807600
                I need to do this:

                int tenure = 0;
                tenure = todayCal.get(Calendar.YEAR) - cal.get(Calendar.YEAR);

                I need to do some other calculations, but the error says its the setTime line. I had that line in there for a couple days now doing other stuff and it was OK until I started adding the other calendars.
                • 5. Re: multiple calendar instances
                  807600
                  jrjan wrote:
                  The error says org.apache.jasper.JasperException: Exception in JSP: /web/ptoSheet.jsp:11. That's really all it says, and this is line 11:

                  11: cal.setTime(currentPTO.getEmploymentDate());
                  Could you try to get some of the stack trace? Perhaps surround that in try/catch and dump the exception so you can see what's actually breaking?

                  Edit: Typo'd

                  Edited by: practissum on Nov 8, 2007 1:16 PM
                  • 6. Re: multiple calendar instances
                    807600
                    sorry, I didn't think you wanted this. Do you know what this means?

                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
                    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
                    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
                    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
                    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
                    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
                    at java.lang.Thread.run(Thread.java:595)
                    in doPost formName=postPtoSheet
                    made it
                    in postPtoSheet tenure=6
                    in postPtoSheet allotment=20
                    org.apache.jasper.JasperException: Exception in JSP: /web/ptoSheet.jsp:11

                    8: PTO currentPTO = (PTO)session.getAttribute("currentPTO");
                    9:
                    10: GregorianCalendar cal = new GregorianCalendar();
                    11: cal.setTime(currentPTO.getEmploymentDate());
                    12:
                    13: GregorianCalendar todayCal = (GregorianCalendar) Calendar.getInstance();
                    14:


                    Stacktrace:
                    at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
                    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:395)
                    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
                    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
                    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
                    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
                    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
                    at edu.cmu.eventsReg.servlets.EventsRegistration.postPtoSheet(EventsRegistration.java:712)
                    at edu.cmu.eventsReg.servlets.EventsRegistration.doPost(EventsRegistration.java:118)
                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
                    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
                    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                    at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
                    at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
                    at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
                    at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
                    at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
                    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
                    at java.lang.Thread.run(Thread.java:595)
                    • 7. Re: multiple calendar instances
                      807600
                      First, just for clarification, the try was emphasized as a pun, not as an exasperated remark on your uselessness. Because you certainly do not seem useless and helpless. :)

                      Second...whoah, that's a lotta stack trace...and I can't decipher any of it (at least as it relates to this issue), just thought maybe there would be more of a hint in there.

                      So, did you say it works if you don't call the second GregorianCalendar? That's quite strange...anyone else out there have any idea?
                      • 8. Re: multiple calendar instances
                        807600
                        Well I don't think it can be line 11 like it says because I've had that line of code in there for a couple of days and it was fine, unless it won't work setting the time for the 1 calendar and then just calling new calendars and not setting the time for them. I didn't know if it could be that or not. How DO you call more than 1 calendar? Did I do it wrong?
                        • 9. Re: multiple calendar instances
                          807600
                          There shouldn't be any problem creating multiple Calendar objects. Have you tried to create a sub program outside of a jsp environment just to verify the logic works? If there is no problem, perhaps it's some weird thing happening elsewhere in the jsp code that is somehow affecting this piece of code.
                          • 10. Re: multiple calendar instances
                            807600
                            I'll put it in my servlet and see if that makes a difference. Thanks.