Skip to content

Instantly share code, notes, and snippets.

@ngocdaothanh
Created March 25, 2017 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngocdaothanh/b878b2d741eb0d866ec21ce007ab97c4 to your computer and use it in GitHub Desktop.
Save ngocdaothanh/b878b2d741eb0d866ec21ce007ab97c4 to your computer and use it in GitHub Desktop.
<%--
Document : one
Created on : 24/03/2017, 3:37:22 PM
Author : Tyler
--%>
<html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login Page</title>
<%
// Retrieve the value (if any) of the form field called 'submitted'
String submitted = request.getParameter("submitted");
// If the Java variable 'submitted' is not null AND 'submitted' equals "yes"
if (submitted != null && submitted.equals("yes")){
%>
<head>
<title>Welcome Page</title>
</head>
<%String fullName = request.getParameter("name");%>
<%String email = request.getParameter("email");%>
<%String pass = request.getParameter("password");%>
<%String gender = request.getParameter("gender");%>
<%String favco = request.getParameter("favcol");%>
<%String tos = request.getParameter("tos");%>
<%
if(tos != null){
%>
<body bgcolor= "<%=favco%>">
<p> Welcome, <%=fullName%>! </p>
<p> Your email is <%=email%></p>
<p> Your password is <%=pass%></p>
<p> Your gender is <%=gender%></p>
<p> Your favourite colour is <%=favco%></p>
</body>
<% } else { %>
<p> Sorry, you must agree to the Terms of Service.<p>
<p> Click <a href="register.jsp">here</a> to go back.<p>
<%}%>
<%
} else {
%>
<form action="one.jsp" method="post">
<table>
<tr><td>Email</td><td><input type="text" name="email"></td></tr>
<tr><td>Full Name</td><td><input type="text" name="name"></td></tr>
<tr><td>Password</td><td><input type="password" name="password"></td></tr>
<tr><td>Gender</td><td><input type="radio" name ="gender" value="male">Male</td></tr>
<tr><td> </td><td><input type="radio" name ="gender" value="female"> Female</td></tr>
<tr><td>Favourite colour</td><td>
<select name = "favcol">
<option value="red">Red</option>
<option value="green">Green</option>
<option value="blue">Blue</option>
<option value="yellow">Yellow</option>
<option value="orange">Orange</option>
<option value="pink">Pink</option>
</select></td></tr>
<tr><td>Agree to TOS<td><input type="checkbox" name="tos" value="tos"></td></tr>
<tr><td></td><td><input type="submit" value="Register"></td></tr>
<input type="hidden" name="submitted" value="yes">
<%
}
%>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment