Collins, Jim wrote:
Hi Guys,

This is probably a dumb question, does anyone know if is possible to use
JavaScript objects from a servlet?


When a user makes some selections I want to add objects to an associative
array I would then like to be able to access this associative array and save
the values to a database from a servlet.

There really isn't a simple way to do this, since for the user-agent to communicate with the servlet, an HTTP request must be submitted (containing the POST or GET data you wish to "say").


You can use JavaScript to create an array of information and then communicate this to the servlet with the submission of a form etc, but you will have to "protect" (encode) the JavaScript data in such fashion as to
1. survive the HTTP transmission
2. be understood by the servlet
I am not sure if JavaScript has built-in serialization to do this. I think it would be easiest to assemble a simple URL-encoded string of data that is then URL-decoded by the servlet and parsed to extract the information.


You may wish to investigate using an applet, since an applet can provide the same dynamic interface as JavaScript in addition to being able to speak "natively" to the servlet.



Erik


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to