Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input to a servlet

Status
Not open for further replies.

Draug

Programmer
Apr 18, 2001
77
CA
Hi,

I have a browser interface, using JavaScript, that recieves input from a user. When the user clicks on submit, the input is then sent to a servlet for processing.

I currently know of two ways to recieve this input.
1. Put the input as parameters in a URL for the servlet.
2. Use the Post method with the servlet to collect the values of everything on the form.

Choice 1 does not suit my needs. There are objects defined in JavaScript that I wish to use in my servlet. I want to access properties of these objects. I cannot seem to pass an object as a parameter in the URL.
Choice 2 does not suit me needs either. There are many, many values on the browser screen, and a few of them will be needed for each execution of the servlet.

What I want to do is send my JavaScript objects to the servlet. On the servlet, I want to access properties of the objects. Can I do this? If so, any ideas how? Can you point me down the right path?

Thanks for your insight,
Draug
 
Hey

Are all the values which you want in your servlet inside a form tag. eg. all your <input type...> etc.

If not then its better if you put all of them inside the form tag, to retrieve it in the servlet.
One more thing, can you be a more clear what the situation is where you want to access a javascript object in a servlet.Please throw some more light on this with an example if possible. Our development team wants to know more to solve your problem

thanks
vikas
 
Thanks for the reply :)

Using the post method with all of my data in a form is exactly what I have done. It works OK.

I should have made it more clear in my original post that the objects I wish to access from the clientside JavaScript are ones that I have created. I created all of my client side code using an Object Oriented methodology. What I do now is put all of the properties of each one of my objects into a form. It would be nice to keep my objects together, and use some of thier methods/attributes inside the servlet as well. As it stands now, I am rewritting the methods I need on the servlet in Java, and just pulling my values from the posted form using request.parameter.

If I can answer any more questions for you, just let me know.

Thank - you.
 
it is possible to read objects from the session. if you can add you object in the page to the session, u should be able to read it into the servlet as is......but i'm not sure how, if at all, it can be done directly from a web page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top