How can i invoke a JavaServlet in JavaScript
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Junaid_Mohammad
Posted On:   Tuesday, December 25, 2001 08:11 PM

I want to call a servlet called = "http://localhost:8080/servlet/contactinfoServlet", but i am getting the following error 405 GET not supported in my code i have done the following function processForm1() { form1 = document.forms["formOne"] if(form1.Customername.value =="") alert("You must fill in your Name!") else if( (form1.Customeraddress.value =="") && (form1.Customerpostcode.value =="") ) alert("You must fill in your full address, including postcode!") else if(form1.Customerpo   More>>

I want to call a servlet called = "http://localhost:8080/servlet/contactinfoServlet", but i am getting the following error


405 GET not supported


in my code i have done the following


function processForm1()


{


form1 = document.forms["formOne"]


if(form1.Customername.value =="")


alert("You must fill in your Name!")


else if( (form1.Customeraddress.value =="") && (form1.Customerpostcode.value =="") )


alert("You must fill in your full address, including postcode!")


else if(form1.Customerpostcode.value =="")


alert("You must fill in your postcode!")


else if( (form1.Customertelephoneno.value =="") && (form1.Customermobileno.value =="") && (form1.Customeremail.value ==""))


alert("You must fill in either your telephone, mobile or email address!")


else
location.href = "http://localhost:8080/servlet/contactinfoServlet"


}


.........
.........



.......


.......



"processForm1()">





The reset button works, so does the submit button, but give me the GET error.



Please can you help!!!

   <<Less

Re: How can i invoke a JavaServlet in JavaScript

Posted By:   Christopher_Schultz  
Posted On:   Wednesday, December 26, 2001 07:07 AM

You are using GET from your 'location.href=...' call.



You should instead return 'false' from your JavaScript method if you want to show an error. Return 'true' if the form validated.



Your submit button should have an onClick='javaScript:processForm1();'. This will cause the submit to fail if the form validation fails.



-chris
About | Sitemap | Contact