Hello, I want to link this JSP page to another JSP page. But it keeps coming back to the same page even though I've response.sendRedirect to another page.

I'm new to JSP so I really have no idea what to do now..

Here are the codes below.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ page import="entity.*" %>

<%
String fullName = request.getParameter("fullName");
String maritalStatus = request.getParameter("maritalStatus");
String height = request.getParameter("height");
String weight = request.getParameter("weight");
String gender = request.getParameter("gender");
String age = request.getParameter("age");
String dateOfBirth = request.getParameter("dateOfBirth");
String placeOfBirth = request.getParameter("placeOfBirth");
String idNo = request.getParameter("idNo");
String countryOfIssue = request.getParameter("countryOfIssue");
String nationality = request.getParameter("nationality");
String race = request.getParameter("race");
String homeNo = request.getParameter("homeNo");
String officeNo = request.getParameter("officeNo");
String mobileNo = request.getParameter("mobileNo");
String address = request.getParameter("address");
String postalCode = request.getParameter("postalCode");
String corrAddress = request.getParameter("corrAddress");
String corrPostalCode = request.getParameter("corrPostalCode");
String emailAddress = request.getParameter("emailAddress");

MainApplicant lifeinsured = new MainApplicant();

lifeinsured.setFullName(fullName);
lifeinsured.setMaritalStatus(maritalStatus);
lifeinsured.setHeight(0);
lifeinsured.setWeight(0);
lifeinsured.setGender(gender);
lifeinsured.setAge(age);
lifeinsured.setDateOfBirth(dateOfBirth);
lifeinsured.setPlaceOfBirth(placeOfBirth);
lifeinsured.setIdNo(idNo);
lifeinsured.setCountryOfIssue(countryOfIssue);
lifeinsured.setNationality(nationality);
lifeinsured.setRace(race);
lifeinsured.setHomeNo(homeNo);
lifeinsured.setOfficeNo(officeNo);
lifeinsured.setMobileNo(mobileNo);
lifeinsured.setAddress(address);
lifeinsured.setPostalCode(postalCode);
lifeinsured.setCorrAddress(corrAddress);
lifeinsured.setCorrPostalCode(corrPostalCode);
lifeinsured.setEmailAddress(emailAddress);

lifeinsured.createMainApplicant();
%>
<%

String command1 = request.getParameter("command");

if ((command1 != null) && (command1.equals("new")))
{
response.sendRedirect("Step2App.jsp");
}
%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Fedora</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>
<body>

<div id="wrapper">

<div id="header">
	<div id="logo">
		<h1><a href="#">Fedora</a></h1>
		<p>Providing the best insurance</p>
	</div>
	<!-- end #logo -->
	<div id="menu">
		<ul>
		
			<li class="active"><a href="InsuranceIndex.jsp" title="Home">Home</a></li>
			<li><a href="LifeInsuredApplication.jsp" title="Applications">Apply for Insurance</a></li>
			<li><a href="UnderwriterIndex.jsp" title="Underwriting">Underwriting Panel</a></li>
			<li><a href="CheckStatus.jsp" title="Check Status">Check Status</a></li>
			<li><a href="#">Find An Agent</a></li>
		</ul>
	</div>
	<!-- end #menu -->
</div>
<!-- end #header -->
<div id="page">
	<div id="header-pic"></div>
	<div id="content" style="width: 898px">
		<div class="post">
			<h1 class="title">
                <strong>SECTION A: PARTICULARS OF LIFE ASSURED / MAIN APPLICANT</strong><br />
            </h1>
               <br>
			<p class="byline" style="text-align: left"><small><span style="font-size: 10pt"><em>Step 1 :<br />
                </em></span>
                <span style="font-size: 13pt"><strong> General Details </strong></span></small></p>
        
				<form name="theForm" method="post" action="">		
			 <table align="center" style="font-size: 9pt">
                            <tr class="alt">
                                <td style="width: 215px; height: 20px;">
                                    Full Name:</td>
                                <td colspan='3' style="height: 20px; width: 536px;">
                                    <input name="fullName" class="textbox" type="text" style="width: 397px; height: 15px;"/></td>
                            </tr>
                            <tr>
                                <td style="width: 215px; height: 20px;">
                                    Marital Status:</td>
                                <td colspan="3" style="height: 20px; width: 536px;">
                                    <input id="Single" type="radio" name="maritalStatus" value="Single" checked="checked" />
                                    Single
                                    <input id="Married" type="radio" name="maritalStatus" value="Married" />
                                    Married
                                    <input id="Divorced" type="radio" name="maritalStatus" value="Divorced" />
                                    Divorced
                                    <input id="Widowed" type="radio" name="maritalStatus" value="Widowed" />
                                    Widowed</td>
                            </tr>
                            
                             <tr class="alt">
                            <td style="width: 215px; height: 20px;">
                                    Height/Weight:</td>
                                    <td colspan="3" style="height: 20px; width: 536px;"><input class="input" name="height" style="height: 15px; width: 68px;"/>(m) &nbsp;
                                        <input class="input" name="weight" style="height: 15px; width: 61px;"/>
                                (kg)</tr>
                            <tr>
                                <td style="width: 215px; height: 20px;">
                                    Gender:</td>
                                <td colspan="3" style="height: 20px; width: 536px;">
                                  <input type="radio" checked="CHECKED" name="gender" value="Male"/>  Male<input type="radio" name="gender" value="Female"/>Female</td>
                            </tr>
                             <tr class="alt">
                                <td style="width: 215px; height: 20px;">
                                    Age:</td>
                                <td colspan="3" style="height: 20px; width: 536px;">
                                    <input name="age" class='textbox' type='text' style="width: 43px; height: 15px;"/></td>
                            </tr>
                            <tr>
                                <td style="width: 215px; height: 20px">
                                    Date of Birth:</td>
                                <td colspan="3" style="height: 20px; width: 536px;">
                                    <input name="dateOfBirth" class="input" style="height: 17px"/>&nbsp;
                                    (dd/mm/yyyy)</td>
                            </tr>
                             <tr class="alt">
                                <td style="width: 215px; height: 20px">
                                    Place Of Birth:</td>
                                <td colspan="3" style="height: 20px; width: 536px;">
                                    &nbsp;<input id="Singapore" checked="checked" name="placeOfBirth" type="radio" value="Singapore" />
                                    Singapore<input id="Others" name="placeOfBirth" type="radio" value="Others" />
                                    Others:<input class="input" name="placeOfBirth" style="height: 15px"/></td>
                            </tr>
                            <tr>
                                <td style="width: 215px; height: 20px">
                                    Identification No:</td>
                                <td colspan="3" style="height: 20px; width: 536px;">
                                    &nbsp;<input id="Radio3" checked="checked" name="IdNo" type="radio" value="NRIC" />
                                    NRIC
                                    <input id="Radio4" name="idNo" type="radio" value="Passport" />
                                    Passport:<input class="input" name="IdNo" style="width: 64px; height: 15px;"/>
                                </td>
                            </tr>
                             <tr class="alt">
                                <td style="width: 215px; height: 20px">
                                    Country of Issue:</td>
                                <td colspan="3" style="height: 20px; width: 536px;">
                                    &nbsp;<input class="input" name="countryOfIssue" style="width: 64px; height: 15px;"/></td>
                            
                            </tr>
                            <tr>
                                <td style="width: 215px; height: 20px">
                                    Nationality:</td>
                                <td colspan="3" style="height: 20px; width: 536px;">
                                    &nbsp;<input id="Radio5" name="nationality" type="radio" value="Singaporean" />Singaporean
                                    <input id="Radio6" checked="checked" name="nationality" type="radio" value="Others" />
                                    Others:
                                    <input class="input" name="nationality" style="width: 60px; height: 15px;"/></td>
                            </tr>
                             <tr class="alt">
                                <td style="width: 215px; height: 20px">
                                    Race:
                                </td>
                                <td colspan="3" style="height: 20px; width: 536px;">
                                    <input class="input" name="race" style="height: 15px"></td>
                            </tr>
                            <tr>
                                <td style="width: 215px; height: 20px;">
                                    Contact No:
                                </td>
                                <td colspan="3" style="height: 20px; width: 536px;">
                                    <input class="input" name="homeNo" style="height: 15px"/>(H)
                                    <input class="input" name="officeNo" style="height: 15px"/>(O)
                                    <input class="input" name="mobileNo" style="height: 15px"/>(HP)</td>
                            </tr>
                             <tr class="alt">
                                <td style="width: 215px; height: 20px">
                                    Residence Address:</td>
                                <td colspan="3" style="height: 20px; width: 536px;">
                                    <input class="input" size="65" name="address" style="height: 15px"/>
                            </tr>
                            <tr>
                                <td style="width: 215px; height: 20px;">
                                    Postal Code:
                                </td>
                                <td colspan="3" style="width: 536px; height: 20px;">
                                    <input class='textbox' type='text' style="width: 86px; height: 15px;" name="postalCode"/></td>
                            </tr>
                             <tr class="alt">
                                <td style="width: 215px; height: 20px;">
                                    Correspondence Address:</td>
                                <td colspan="3" style="height: 20px; width: 536px;">
                                    <input class="input" size="65" name="corrAddress" style="height: 15px"/>
                                 </td>
                            </tr>
                                  <tr>
                                <td style="width: 215px; height: 20px;">
                                    Postal Code:
                                </td>
                                <td colspan="3" style="width: 536px; height: 20px; ">
                                    <input class='textbox' type='text' style="width: 86px; height: 15px;" name="corrPostalCode"/></td>
                            </tr>
                            <tr class="alt">
                                <td style="width: 215px; height: 20px;">
                                    Email Address:</td>
                                <td colspan="3" style="width: 536px; height: 20px;">
                                    <input class="input" size="65" name="emailAddress" style="height: 15px"/></td>
                               
                            
                            </tr>
                               <tr>
                                <td colspan="4" style="height: 20px">
                                    <input type="submit" value="Next" style="height: 22px"/>
                                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
                                </td>
                            </tr>
                        </table>
          
	</form>

		
		<div class="post">
			<p class="byline"> 
                <br />
                <a href="#" class="more"></a>&nbsp;</p>
		</div>
	</div>
	<!-- end #content -->
	<!-- end #sidebar -->
	<div style="clear:both; margin:0;"></div>
</div>
<!-- end #page -->

</div>

<div id="footer">
	<p>
        Copyright &copy; 2008 Fedora Insurance Co. Designed by Strider Studios</p>
</div>
<!-- end #footer -->
</body>
</html>
<form name="theForm" method="post" action="">

Where it says action you need to put the jsp which you want to go after submiting the form. If it is let empty, it is submitted to the same form.
So try this:

<form name="theForm" method="post" action="anotherPage.jsp">

You can also put servlets at the 'action'

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.