I want to refresh the chart in jsp with MYSQL.
To draw bar chart i used following code:
Now, i want to refresh this chart every 30 secs. & change database in MySQL. How is it possible ? Any repl. vl b appreciated. This is urgent. Very nice Forum...Like it..Thank you...!
This message was edited 1 time. Last update was at by Devaka Cooray
Welcome to JavaRanch. Please note that accessing the database from a JSP is a really bad practice. Choose another model.
Please UseCodeTags when you post a code in future. It's unnecessarily hard to read the code otherwise.
Devaka Cooray wrote:
Please note that accessing the database from a JSP is a really bad practice.
Yeh that's why I asked if he is going to host this in an actual environment.. Also absolute path like "c:\s2s worksspace\s2sgateway\WebContent\chart.jpg" is not a good idea..
This message was edited 1 time. Last update was at by Ayoma Wijethunga
I think this topic is in the wrong forum (" JavaRanch » Forums » Products » Other Open Source Projects ")
Meet Garvalia
Greenhorn
Joined: Mar 16, 2010
Posts: 7
posted
0
Thank you very much for your suggestions. I will apply and take care to post thread.
Actually i am going to develop real time stock update chart using Ajax+java script+My sql+java server pages+eclispe. I have created a table in My Sql, i want to change it automatically and update chart according to it. But i am a new to dis environment so, any suggestion or code will be appreciated. ie. how & which techs to use? This is Urgent. Thank you for your suggestions.
This message was edited 1 time. Last update was at by Meet Garvalia
Ayoma and I have already mentioned some good practices for your requirement.
You may also need to understand about how to apply some Design Patterns.
Have a look at this article
Yes. As Devaka mentioned, it is not clear what to say as a reply.
Anyway in this kind of a project you'll surely have to go for a client side technology. If you are more familiar with JavaScript, then no problem go ahead with JavaScript+ AJAX. Or else you can use JavaFX or similar technology. JSP seems to be a must, as you have already selected JSP as your server side language. Then MySQL really couples with Java and that sounds to be a good choice.
So your choice "Ajax+java script+My sql+java server pages" is a good one. Finally checkout Netbeans IDE. I'm a Netbeans fan at the moment
Regards.
Meet Garvalia
Greenhorn
Joined: Mar 16, 2010
Posts: 7
posted
0
Thank you. I worked on the ajax as ayoma suggests. I am posting entire code.
I exported db and refresh the page so got it what i wanted to. Than you ayoma once again
You are welcome Meet.. As I can see, one more change is required to make this work correctly. Your browser error log might be showing some errors at the moment.
Are you writing the AJAX part in JSP itself? Or do you have a JSP file and a HTML file separately for AJAX request.
Anyway, ignore that if code is working as same as you expected, with 30second auto refresh.
Regards...
Meet Garvalia
Greenhorn
Joined: Mar 16, 2010
Posts: 7
posted
0
Ayoma Wijethunga wrote:
Meet Garvalia wrote:Thank you ayoma once again
You are welcome Meet.. As I can see, one more change is required to make this work correctly. Your browser error log might be showing some errors at the moment.
Are you writing the AJAX part in JSP itself? Or do you have a JSP file and a HTML file separately for AJAX request.
I am writing AJAX part in JSP itself.Which type of error your talking about ?
When i load new db it should be auto refreshed after 30secs ? or i have to refresh it ?
Rightnow i refresh it..then new db is seen in chart.
Ah ok... you asked for 30second auto refresh, didn't you? I send you the code for that. In your new code, you are not using AJAX part at all. It's just there and that trick won't be effective unless you put JSP and HTML in separate files. That's why we don't use JSP to access data base or for business logic.
Anyway let me just make it easy for you. Use this HTML instead of what you are using now. So you'll get 30second auto reload.
Meet Garvalia
Greenhorn
Joined: Mar 16, 2010
Posts: 7
posted
0
You are right. I want to use Ajax but not gettin how ? do i put ajax script in different file than jsp ? then how can i debug it ? I am a new 2 dis... thank you..
This message was edited 1 time. Last update was at by Devaka Cooray
Yeh.. Devaka is correct.. There is no point of trying to implement AJAX if you are almost new. Try some articles. Most of all do some practice. Anyway this is how you should implement the code I added you few days before.