Hi I am new to JSP so I may be wrong in some terminology.
I am familiar with ASP way of doing thing so I do no much about javabean or servet, hence would try to avoid it an stick to pure JSP.
I need help in improving this JSP web page. Especially the email validation and maintaining the value when submit fail. So far things seem fine(lack the email validation), but can someone please improve this script for me. Thanks
<%
String title, firstname,email
String submit = request.getParameter("submit");
boolean msg_summary = false;
String message = "";
if ((submit==null)||(submit.equals("")))
{
msg_summary = false;
title="";
firstname = "";
email="";
}
else
{
title = request.getParameter("title");
firstname = request.getParameter("firstname");
email = request.getParameter("email");
message = "Please complete the following;";
if ((title==null)||(title.equals(""))){
message = message + "<BR>Title";
msg_summary = true;
}
if ((firstname==null)||(firstname.equals(""))){
message = message + "<BR>Firstname";
msg_summary = true;
}
if ((email==null)||(email.equals(""))){
message = message + "<BR>Email";
msg_summary = true;
}
}
%>
<%if ( msg_summary) { %>
<%= "<font color=\\"red\\">" + message + "</font>" %>
<% } %>
<form action="#" method="post">
<input type="hidden" name="submit" value="y">
<table border="0" width="100%">
<tr>
<td width="15%"> </td>
<td width="30%"> </td>
<td width="15%"> </td>
<td width="40%"> </td>
</tr>
<tr>
<td>Title<font color="#FF0000">*</font></td>
<td><select name="title">
<option value="" selected >Please select</option>
<option <%if (title.equals("Mr.")){out.write("selected");} %>>Mr.</option>
<option <%if (title.equals("Mrs.")){out.write("selected");} %>>Mrs.</option>
<option <%if (title.equals("Ms.")){out.write("selected");} %>>Ms.</option>
<option <%if (title.equals("Miss")){out.write("selected");} %>>Miss</option>
</select></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>First name<font color="#FF0000">*</font></td>
<td><input type="text" name="firstname" maxlength="50" value="<%=firstname%>"></td>
<td>Last name<font color="#FF0000">*</font></td>
<td><input type="text" name="lastname" maxlength="50" value="<%=lastname%>"></td>
</tr>
<tr>
<td>Phone</td>
<td><input type="text" name="phone" maxlength="20" value="<%=phone%>"></td>
<td>Email address<font color="#FF0000">*</font></td>
<td><input type="text" name="email" maxlength="50" value="<%=email%>"></td>
</tr>
<tr>
<td> </td>
<td colspan="3"><input type="submit" name="create" value="Create My Profile">
<input type="button" name="cancel" value="Cancel">
</tr>
</table>
</form>