=========
<body>
<form action="first.jsp" >
<p>Please enter your name : <input type="text" name="suserName" ></p>
<p>Please enter your address : <input type="text" name="saddress" ></p>
<p>Please enter your Age : <input type="text" name="sage" ></p>
<p><input type="submit" value="Submit" ></p>
</form>
</body>
first.jsp
=========
<%
out.println("first servlet");
String name = request.getParameter("suserName");
String addr = request.getParameter("saddress");
String ag = request.getParameter("sage");
int age = Integer.parseInt(ag);
out.println("<br /><br />");
if(age < 18){
%>
<jsp:forward page="minor.jsp">
<jsp:param name="message" value="Hello, how are you" ></jsp:param>
<jsp:param name="wish" value="Have a nice day" />
</jsp:forward>
<%
}
else
{
%>
<jsp:include page="major.jsp" >
<jsp:param name="id" value="A123" />
<jsp:param name="name1" value="Mohan" />
</jsp:include>
<%
}
%>
major.jsp
=========
<%
out.println("<br/><br/>");
String id1 = request.getParameter("id");
String name2 = request.getParameter("name1");
out.println("<br /><br />");
out.println("Your name is :"+name2);
out.println("<br/><br/>");
out.println("Your ID is :"+id1);
out.println("<br/><br/>");
%>
minor.jsp
=========
<%
String message1 = request.getParameter("message");
String wish1 = request.getParameter("wish");
out.println("<br /><br />");
out.println("Message :"+message1);
out.println("<br/><br/>");
out.println("wishes : "+wish1);
out.println("<br/><br/>");
%>
No comments:
Post a Comment