Results 1 to 1 of 1
  1. #1
    peace76 is offline Member
    Join Date
    Apr 2010
    Posts
    18
    Rep Power
    0

    Default Problem with TimeStamp.

    Can mabey someone please explain this to me.

    When a user enter a note on my wall, ill persist it to mysql db, I then read the db and display it again with the new note included.

    BUT the (timeStamp) date dont show until I restart the browser, I have the data saved in the same database/table. :confused: What am I doing wrong ?

    some code below.


    Servlet.java
    Java Code:
    else if (!userPath.isEmpty() && userPath.equals("/enterWallNote")) {
    
                String eventId = request.getParameter("eventid");
    
                String body = request.getParameter("body");
    
                Events event = (Events) eventsFacade.find(Integer.parseInt(eventId));
    
    
                EventWall eventWall = new EventWall(body, event, user);
    
                // save posts
                eventWallFacade.postNote(eventWall);
    
                // get saved posts
                List notes = eventWallFacade.readNotes(event);
    
                request.setAttribute("notes", notes);
                request.setAttribute("result", "handleThisEvent");
                userPath = "/empty";
    }
    eventWallFacade
    Java Code:
        ......
        public void postNote(EventWall eventWall) {
            em.persist(eventWall);
        }
    
        public List readNotes(Events event){
            Query q = em.createNamedQuery("custom.findByEvent");
            q.setParameter("events", event);
            try {
                return (List) q.getResultList();
            } catch (NoResultException nr) {
                return null;
            }
        }
    view.jsp
    Java Code:
    <c:if test="${!empty notes}">
                            <c:forEach var="note" items="${notes}">
                                <div id="wallHead">${note.users.name} - ${note.postDate} <br /></div>
                                <div id="wallBody">${note.body}</div>
                            </c:forEach>
    </c:if>
    Entity
    Java Code:
        @Basic(optional = false)
        @Column(name = post_date")
        @Temporal(TemporalType.TIMESTAMP)
        private Date postDate;
    
    public Date getPostDate() {
            return postDate;
        }
    
    public void setPostDate(Date postDate) {
            this.postDate = postDate;
        }
    Last edited by peace76; 01-04-2011 at 02:53 PM.

Similar Threads

  1. Timestamp Issue
    By hacktorious in forum Advanced Java
    Replies: 2
    Last Post: 12-19-2010, 07:03 AM
  2. To_date function through Java shows timestamp
    By mpavithra in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 07-29-2010, 09:59 AM
  3. how to compare two timestamp
    By baktha.thalapathy in forum New To Java
    Replies: 1
    Last Post: 06-11-2010, 11:05 AM
  4. Timestamp in SQL format
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-10-2008, 12:37 PM
  5. Date as String to TimeStamp
    By ironballs in forum Advanced Java
    Replies: 1
    Last Post: 08-01-2007, 02:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •