I am writing a web based application using JSP and JDBC. In side a servlet I execute some code like this

DAO.addComments( commentsBean ); 
commentsList = DAO.getComments(); 
session.setAttribute( "comments", commentsList ); 
response.sendRedirect( "comments.jsp" );

when I move to comments.jsp I find all the comments except those that have been just added by the servlet code written above using addComments(). The next time I access the same page "comments.jsp" that missing comments appear.

The same problem occurs when I delete some comments, the deleted comments still appear on the comments.jps page when I visit the page just after deleting the comments form inside the servlet by calling the DAO method.

So many thanks if someone could guide me properly, about what is the issue (problem).

Good Bye.

Offhand it would be difficult to point out the actual cause of your application _not working_ but I guess the collection used to hold values is not getting updated or the DAO methods are returning rogue values in your case. Without more code, I don't think anyone would be as such able to lend a helping hand.

Hi
are u executing your code for fetching the comments in a separate thread inside this method?
DAO.getComments();

If yes..try removing thread.

I am not sure how you are implementing DAO....just a wild guess though.

Regards
sam.n

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.