Hi, this is for an unsubscribe page in which a user specifies their email address in a text box and that entry is checked in the database. If they are found the "future_promo" field is changed from a "Y" to a "N" and the "opt_out_date" field is populated w/ the systemdate. The user is then redirected to a thankyou page. The problem I am running into is how do I redirect the user to another page if their name isnt in the database. So I want to have two pages one with a thank you message and one with an I'm sorry we are unable to located your name in our database. Here is my code for the jsp page:
<%@ page import="java.lang.*, java.util.*, java.io.*, javax.servlet.*, javax.servlet.http.*, java.sql.*" %>
<%
//loading the JDCB driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Defining the connection URL
String host = "NCSPRD01.RAR.NCSUS.JNJ.COM";
String dbName = "CPC1";
int port = 1523;
String oracleURL = "jdbcracle:thin" + host + ":" + port + ":" + dbName;
//Establish the connection
String username = "WWIM";
String password = "WWIM12";
String email = request.getParameter("txtEmail").trim();
Connection cn=null;
cn = DriverManager.getConnection(oracleURL, username, password);
// Query to get email value from db
Statement statement = cn.createStatement();
String UpdateKySampling = "Update kyTest Set Future_Promo = 'N', opt_out_date = sysdate where email = " +
"("+"'"+email+"')";
String commit = "commit";
//Execute the Update
statement.executeUpdate(UpdateKySampling);
statement.executeUpdate(commit);
statement.close();
cn.close();
%>
<html>
<head>
<title>Welcome to K-Y.com!!</title>
<link href="/css/ky.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--INCLUDE HEADER-->
<jsp:include page="/include/navigation/index.html" flush="true" />
<p align="center"><b>
<span class="ProdJelly">You have been successfully unsubscribed.
Click here to go back to:<p align="center"><a href="http://www.ky.com">www.ky.com</a></b></p></span>
</body>
</html>
Thanks in advance.
<%@ page import="java.lang.*, java.util.*, java.io.*, javax.servlet.*, javax.servlet.http.*, java.sql.*" %>
<%
//loading the JDCB driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Defining the connection URL
String host = "NCSPRD01.RAR.NCSUS.JNJ.COM";
String dbName = "CPC1";
int port = 1523;
String oracleURL = "jdbcracle:thin" + host + ":" + port + ":" + dbName;
//Establish the connection
String username = "WWIM";
String password = "WWIM12";
String email = request.getParameter("txtEmail").trim();
Connection cn=null;
cn = DriverManager.getConnection(oracleURL, username, password);
// Query to get email value from db
Statement statement = cn.createStatement();
String UpdateKySampling = "Update kyTest Set Future_Promo = 'N', opt_out_date = sysdate where email = " +
"("+"'"+email+"')";
String commit = "commit";
//Execute the Update
statement.executeUpdate(UpdateKySampling);
statement.executeUpdate(commit);
statement.close();
cn.close();
%>
<html>
<head>
<title>Welcome to K-Y.com!!</title>
<link href="/css/ky.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--INCLUDE HEADER-->
<jsp:include page="/include/navigation/index.html" flush="true" />
<p align="center"><b>
<span class="ProdJelly">You have been successfully unsubscribed.
Click here to go back to:<p align="center"><a href="http://www.ky.com">www.ky.com</a></b></p></span>
</body>
</html>
Thanks in advance.