This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Post to my servlet through java script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Post to my servlet through java script" Watch "Post to my servlet through java script" New topic
Author

Post to my servlet through java script

jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
My Servlet does not receive my form data; therefore temp below is null.


I suppose the problem comes from somewhere in my JSP page:



or here, where i try to submit my data (yes my lat/lng values and name values are valid):



Also, the submit causes my browser to load up the servlet page......i don't want that......I just want the Servlet to handle database updates.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Moved to the HTML forum as ths is not a servlet question.

The problem has nothing to do with servlets, or even JavaScript, but with the HTML.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

A couple of things. Firstly, loose the all-uppercase in your HTML. It's no longer 1996.

Secondly, your form action should not have the absolute URL. Remove the server part of the URL.

Lastly, your form elements have no names. You must use the name attribute to assign the names to be used when the elements are submitted as a request.
jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
Thanks Bear,

It's running as it should now.

I'll loose the caps too.....shame cause i like the way it looks.

Is there anything i can do to stop the browser from switching from my JSP page to the Servlet page.

the submit causes my browser to load up the servlet page......i don't want that......I just want the Servlet to handle database updates.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

jite eghagha wrote:I'll loose the caps too.....shame cause i like the way it looks.

It really is up to you, but most people find all uppercase hard to read, and it makes your code look very old-fashioned and dated.

Is there anything i can do to stop the browser from switching from my JSP page to the Servlet page.

That is a completely different question that you should start a new post for in the Servlets forum.
amrish sharma
Greenhorn

Joined: Sep 24, 2009
Posts: 20
jite eghagha wrote:My Servlet does not receive my form data; therefore temp below is null.


I suppose the problem comes from somewhere in my JSP page:



or here, where i try to submit my data (yes my lat/lng values and name values are valid):



Also, the submit causes my browser to load up the servlet page......i don't want that......I just want the Servlet to handle database updates.


use ajax post simply
Note:- but ajax is not cross browser compatible
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Note:- but ajax is not cross browser compatible

It is if you're using a modern JavaScript library.
 
jQuery in Action, 2nd edition
 
subject: Post to my servlet through java script
 
Similar Threads
How to change values of buttons and textfields.
Ajax Calls not refereshed.
request a parameter on the same JSP page
mutipart/form-data
automatic form submit