• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

To retrieve data from the database

 
S.R.K.Vivek Raju
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I have a simple question, Can I retrieve data from the Mysql database on page load. i.e i am storing the information from page one and i want to retrieve that stored information on my page two. And this should be retrieved on page load.

Is this possible, if yes could anybody guide me with some tips.

Thanks

With Regards
S.R.K.Vivek Raju.
 
todd runstein
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you talking about web pages? If so, retrieve the data as page one is being created and store the results in a session attribute. You can simply write the data to the page for page one. For page two, have it simply pull out the data from the session attribute and write the data to the page.

If you're talking about using the "onload" attribute of the html body tag, you'd need to do this through javascript and XmlHttpRequest object. I guess I'm having trouble determining whether you mean "on page load" literally or not.

Hope that helps
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34396
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While JDBC is mentioned, this is really a question on how web pages work. Moving to Servlets.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"page load" is not a servlet/JSP phrase either.

Are you talking about the the Javascript "onLoad" event?
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well the question isn't clear, but I will take a stab at it anyway. The short answer is no matter which meaning you have it can be done.

If by 'page' you mean servlet/jsp and by 'load' you mean on 'request' then you can access get data in page 1 and access it in page 2. This can be done by putting the data into session, request, application, page, or static scope among others. In jsp these are all implicit variables.

If by 'page load' you mean when the servlet/jsp is first loaded it can also be done by coding the servlets 'jspInit' method or the servlets 'init' method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic