This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Not Getting the Latest data from databases in jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Not Getting the Latest data from databases in jsp page" Watch "Not Getting the Latest data from databases in jsp page" New topic
Author

Not Getting the Latest data from databases in jsp page

sadhu charan
Greenhorn

Joined: Nov 27, 2012
Posts: 18
Hi i am trying to fetch Latest Data from Databases in a continous manner for a particular time interval , i am getting but data not display in front page in a continous way it only display old data what shoud i do , I am using javascript ,core java with Oracle Database


Thanks
Scp
Krutik pandya
Greenhorn

Joined: Dec 17, 2012
Posts: 6

Hi,

if you are not using ajax then I believe that you are using simple javscript code to generate the event to call requesting Page. Please check that how you are storing the result set data and getting data on jsp.

You can utilize collections classes to store result data pass it in the request on jsp page.

if you are doing same. post sample of code you are implementing.

Cheers,

Krutik
sadhu charan
Greenhorn

Joined: Nov 27, 2012
Posts: 18
Hi Krutik
I am using javascript setTimeInterval method and calling java method got the value but its continuosly not display value only it display value while it is loading the page , if you have Ajax sample or code which continuosly checking Database and display data then help me


Thanks
Scp
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

It would be useful if we had some idea of how you were calling a Java method from your Javascript code. Right now we have essentially no information about what you are doing, so making suggestions about what you should be doing is clearly impossible. So show us how you are doing that.
sadhu charan
Greenhorn

Joined: Nov 27, 2012
Posts: 18
Hi i am just using setTimeInterval method inside setinterval methods i call a java function which get the data from data base Like:-

My code is like thats but it fetching only once not a one second interval , so if you have any ajax code or sample please send it

Thanks
Scp



Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Ah, I see. You are making a common mistake, namely you think that the HTML scriptlet is repeatedly evaluated in the browser. That isn't the case -- your JSP runs on the server and generates HTML (including Javascript) which is interpreted by the browser. If you use the "Display Source" feature in your browser you'll see that this is the case.

But for a better explanation, read The Secret Life of JavaServer Pages.

And yes, to do what you want to do you are going to have to use Ajax. However asking for random fragments of Ajax to be posted isn't going to be very useful, you're going to have to spend some time learning about it. Snippets aren't the way to go.
Krutik pandya
Greenhorn

Joined: Dec 17, 2012
Posts: 6

yes, ajax is the way in your case. you ask the sample code. however, It will be better, you get basic idea and learn ajax first rather asking direct help.

W3school site is very nice to begin with ajax.

cheers,

Krutik
J. Kevin Robbins
Bartender

Joined: Dec 16, 2010
Posts: 826
    
  13

Ajax is a lot less painful if you use jQuery. I highly recommend jQuery in Action by our own beloved Bear.


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not Getting the Latest data from databases in jsp page
 
Similar Threads
The import org.apache.commons.lang.StringEscapeUtils can not be resolved
Controlling values in JSF.
Jrame not visible when Try to run from Unit Test
Sending a jsp page as the content of an email
JSP pages list view and grid view