Practical 4b
Practical 4b
1. Index.html
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form action="Validate.jsp">
2. Validate.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
import="mypack.*">
<title>JSP Page</title>
</head>
<body>
<h1>Validation Page</h1>
<jsp:useBean id="obj" scope="request" class="mypack.CheckerBean" >
<jsp:setProperty name="obj" property="*"/>
</jsp:useBean>
<%
if (obj.validate())
{
%>
<jsp:forward page="successful.jsp"/>
<%
}
else
{
%>
<jsp:include page="index.html"/>
<%
}
%>
<%=obj.getError() %>
</body>
</html>
3. CheckerBean.java
package mypack;
public CheckerBean() {
error="";
}
4. Successful.jsp
Output:
Case1: Enter Invalid Data
Case2: Enter Valid Data