can i check with you all,how do i code to get the parameters from textbox in javascript and pass the parameters to
the servlet after a button is click.


just submit the form to the servlet, then you can use request.getParameter to get the parameters

Hi Thirusha,
do you have any example on how do i code the javascript?thanks!:)


I dont have code, since this is very simple, the textbox you are refering to is most probably from a html page. so all you have to do is surround it with form tags, then in the action parameter place the url for the servlet, the button you can either have it as type submit or if it is of type button, add an onlick event then use document.formname.submit;
formname being the name of the form which surrounds the text box.

Hi i tried the method that you had said. Did I do anything wrongly?

<form name = "form1" action="" method="post">
 	Name: <input type="text" name="name" /><br />
  	Date: <input type="text" name="date" /><br />
	Time: <input type="text" name="time" /><br />
	Location: <input type="text" name="location" /><br />
	Message: <input type="text" name="message" /><br />
  <input type="submit" value="Submit" onclick="document.form1.submit"/>

it still does not work.thanks for your help:)

You dont put the full url in the action parameter unless you are submitting to a different server, if it is on the same server then


should suffice, but i am not sure how the servlet is accessed (this depends on your servlet mapping parameter in the web.xml file), so it could be the action as specified above or just "AddEventServlet"

Also if u have a submit type button there is no need for an onclick event.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.