I have this form in jsp page –
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="./Styles/Site.css" type="text/css" />
<title>Create new customer</title>
</head>
<body>
<fieldset>
<legend>Create new customer</legend>
<form action="CreateCustomerServlet" method="GET">
ID : <input type="text" name="customerId" />
<br />
First Name : <input type="text" name="customerFirstName" />
<br />
Last Name : <input type="text" name="customerLastName" />
<br />
Phone : <input type="text" name="customerPhone" />
<br />
Gender : <input type="radio" name="customerGender" value="Male">
Male <input type="radio" name="customerGender" value="Female">
Female
<br>
Password :<input type="password" size="25" name="customerPassword"><br/>
re-Password :<input type="Password" size="25" name="reCustomerPassword">
<br />
<input type="submit" value="Create customer" />
</form>
</fieldset>
<%
// java section , here I want to control on the texts of the form
%>
</body>
</html>
How can I do that when press on the submit button the runnig will enter to the java section and there will be actions on the texts of the form like validation and etc ?
Edit :
I will note , I want to check the texts in the java section before it will be sent to the servlet.
First of all you have to add some information in your code…
In the form tag:
– You have first to assign a ‘method’ value to define which protocol you will use.
– You have to assign an ‘action’ value to say where the form will take the values.
I think there’s much more steps, and you should read some tutorials, etc.
You need some technology to handle the form submission.
If you like to use servlets, there’s a good link
You can user some framework to do that, but it takes more work to learn. You can use Struts, Spring, etc…
Update:
So you want to validate your data…
I suggest you to use some framework, specially Spring MVC. It helps you validating your forms. Without a framework, validating data is a massive work, using javascript or other technogies that are not so dedicated to this end…
Further, Spring MVC helps you with more other things, that you will need later…
Here is a simple Hello World example
Hope it helps…