Hi, I am writing a 'form' where I need to check if text boxes are null (empty), before the next page is displayed. Here is my code so far:
<%@page import="reg.Register"%>
<
jsp:useBean id = "newcust" class="reg.Register" scope ="session"/>
<jsp:setProperty name ="newcust" property="*" />
<% if(request.getParameter("Continue")!=null){
%>
<%!
String lname="";%>
<%
if (request.getParameter("lastName")==null){
lname = "Please enter last name";
response.sendRedirect("Register1.jsp");
}
%>
<jsp:forward page="Register2.jsp"/>
<%}%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body>
<span id="Layer1" style="position:absolute; left:610px; top:15px; width:358px; height:23px; z-index:10">
<div align="right"><font color="#0000FF" size="3" face="Lucida Console"><a href="FrontPage.jsp">Home</a>
<a href="SignIn.jsp">Sign In</a> <a href="SignOut.jsp">Sign Out</a> <font color="#000000">Register</font>
Help</font></div>
</span>
<div id="Layer2" style="position:absolute; left:9px; top:82px; width:137px; height:83px; z-index:11">
<table width="146" border="0" cellpadding="2">
<tr>
<td><font color="#0000FF" size="3" face="Lucida Console">My Bazaar</font></td>
</tr>
<tr>
<td><font color="#0000FF" size="3" face="Lucida Console">Browse</font></td>
</tr>
<tr>
<td height="20"><font color="#0000FF" size="3" face="Lucida Console"><a href="Sell.jsp">Sell</a></font></td>
</tr>
<tr>
<td><font color="#0000FF" size="3" face="Lucida Console">Search</font></td>
</tr>
</table>
</div>
<div id="Layer3" style="position:absolute; left:785px; top:509px; width:96px; height:17px; z-index:15"><font color="#FF0000" face="Lucida Console">*</font><font color="#FF0000">required
fields</font></div>
<form method = post action = "Register1.jsp">
<div id="Layer5" style="position:absolute; left:191px; top:126px; width:351px; height:255px; z-index:14"> <form name="form1" method="post" action="">
<table width="342" height="389" border="0" cellpadding="2">
<tr>
<td width="63"><font color="#FF0000" face="Lucida Console">*</font><font face="Lucida Console">Title
: </font></td>
<td width="145"><font face="Lucida Console">
<select name="title">
<option>Mr</option>
<option>Mrs</option>
<option>Ms</option>
</select>
</font></td>
</tr>
<tr>
<td><font color="#FF0000" face="Lucida Console">*</font><font face="Lucida Console">Surname
: </font></td>
<td><font face="Lucida Console">
<%=lname%>
<input name="lastName" type="text" id="lastName">
</font></td>
</tr>
<tr>
<td><font color="#FF0000" face="Lucida Console">*</font><font face="Lucida Console">Firstname
: </font></td>
<td><font face="Lucida Console">
<input name="firstName" type="text" id="firstName">
</font></td>
</tr>
<tr>
<td height="52"><font color="#FF0000" face="Lucida Console">*</font><font face="Lucida Console">Street
Address : </font></td>
<td><font face="Lucida Console">
<input name="addressLine1" type="text" id="addressLine1">
</font></td>
</tr>
<tr>
<td><font face="Lucida Console"> </font></td>
<td><font face="Lucida Console">
<input name="addressLine2" type="text" id="addressLine1">
</font></td>
</tr>
<tr>
<td><font color="#FF0000" face="Lucida Console">*</font><font face="Lucida Console">City
: </font></td>
<td><font face="Lucida Console">
<input name="city" type="text" id="city">
</font></td>
</tr>
<tr>
<td><font color="#FF0000" face="Lucida Console">*</font><font face="Lucida Console">County
: </font></td>
<td><font face="Lucida Console">
<input name="county" type="text" id="county">
</font></td>
</tr>
<tr>
<td><font color="#FF0000" face="Lucida Console">*</font><font face="Lucida Console">Postcode
: </font></td>
<td><font face="Lucida Console">
<input name="postCode" type="text" id="postCode">
</font></td>
</tr>
<tr>
<td><font color="#FF0000" face="Lucida Console">*</font><font face="Lucida Console">Phone
number :</font></td>
<td><font face="Lucida Console">
<input name="phone" type="text" id="phone">
</font></td>
</tr>
<tr>
<td><font color="#FF0000" face="Lucida Console">*</font><font face="Lucida Console">Country
: </font></td>
<td><font face="Lucida Console">
<input name="Country" type="text" id="Country">
</font></td>
</tr>
<tr>
<td><font color="#FF0000" face="Lucida Console">*</font><font face="Lucida Console">Date
of Birth : </font></td>
<td><font face="Lucida Console">
<input name="dob" type="text" id="dob">
</font></td>
</tr>
<tr>
<td><font face="Lucida Console"> </font></td>
<td><font face="Lucida Console">
<input name="Continue" type="submit" id="Continue" value="Continue">
</font></td>
</tr>
</table>
</form>
</div>
<div align="right"></div>
<span id="Layer9" style="position:absolute; left:613px; top:33px; width:172px; height:38px; z-index:9"><img src="l.jpg" width="389" height="48"></span>
<div align="right">
<p> </p>
<p align="left"> </p>
</div>
</body>
</html>
The above does not work (and you can probably tell that am new to jsp).
lname is the attribute that I want to display the error message, obviously above the lastName text box. The problem I am having is that I dont know how to stucture the if (if-else) statements.
Thanks for the help in advance
Jitesh