First Page

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1> Register
</h1> 
<form method="post" action="welcome.jsp">
<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 rowspan="2">Gender</td><td><input type="radio" name="gender">Male</td></tr><tr><td><input type="radio" name="gender">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><td><input type="checkbox" name="tos"></td></tr>    
<tr><td></td><td><input type="submit" value="Register"></td></tr>
</table>
</form>
</body>
</html>

**Second Page **

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body bgcolor="">    
<%
    String name = request.getParameter("name");
    String email = request.getParameter("email");
    String password = request.getParameter("password");
    String gender = request.getParameter("gender");
    String tos = request.getParameter("tos");
    String favcol = request.getParameter("favcol");
%>    
<%
    if (tos != null) {
%>
<p>Welcome, <%=name %>!</p>
<p>Your Email is <%=email %>.</p>
<p>Your password is <%=password %>.</p>
<p>Your gender is <%=gender %>.</p>
<p>Your favourite colour is <%=favcol %>.</p>
<% }
else {    
%>
<p>Sorry, you must agree to the Terms of Service.</p>
<p>Click <a href="register.jsp">here</a> to go back</p>
<% } %>
</body>
</html>

Question
I'm looking for the solution for the background colour of the 2nd page that depends on what favourite colour the user chose at the 1st page. I'm new to these things, please help me. Thank you!

hi,
i dont this is better idea or not but it gives a solution for you by using expression tag

change you code as follows

// get the values before body tag starts and place the selected color value for bgcolor attribute as shown bellow

  <body bgcolor="<%= favCol%>">  

try this once.

reply me incase if you have any issue with my response

NOTE: suggest me if i am wrong

Hi,
please mark this thread as solved or atleast close if you get the answer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.