0

I'm working on a project that the web page will fetch the data from java hashtable object in jsp page. I'm using a jsp for gerenated the web page based on HTML. The data is stored in the java hasbtable object on the server. I want to try to make an AJAX call to fetch the data from the server, then display it in the jsp page.

I just want to know if this is possible to do that by make an AJAX call to access the java hashtable object, then fetch the data back to the client side.

Thanks

Here is the test.jsp page which contain the hashtable obejcts:

Hashtable generalTable = (Hashtable) metaDataTable.get("General");
Hashtable adminTable   = (Hashtable) metaDataTable.get("Administration");

My inital approach is to make an AJAX call to this test.jsp page. Then try to access those two GeneralTable and adminTable hashtable objects. In those two obejcts, it contains the values I would like to fetch.

Unfortunately, I don't have the code yet for my part because I don't know if this is possible or not.

R.Spark
  • 955
  • 2
  • 16
  • 22
  • Yes, surely it's possible. Do you have a more specific programming question? At what step exactly are you stucking while implementing accordingly? This question is way too broad. – BalusC Jan 06 '12 at 15:37
  • Now, I know this is possible. I'm going to write my code and see if I can access those Hashtable objects. Please see my updated post. – R.Spark Jan 06 '12 at 15:55
  • Well, start learning the basic concepts around JSP, Servlets and Ajax separately and do the math. This related question may be helpful: http://stackoverflow.com/questions/4112686/how-to-use-servlets-and-ajax – BalusC Jan 06 '12 at 15:56
  • Thanks, now I know it's possible to do it, so I can try to write some codes first. If there's any question, I will continue to update here. – R.Spark Jan 06 '12 at 16:13

1 Answers1

0

Yes, it's possible, but you will need to have some server-side code to deal wit the request for the data you want, just like with any other AJAX functionality in any other system.

One way to do this would be to have a "special" jsp that gives you back the data you need without any of the typical HTML. Having the special jsp output it's data as a JSON object will make your life much easier in the client-side code.

cdeszaq
  • 30,869
  • 25
  • 117
  • 173