Servlet login redirect to different jsp












1















I need help with redirecting to different page after login.

I manage to do normal login redirect to appDashboard.jsp however, what I'm trying to do is if the user first-time login into the system then they will be redirected to appSetup.jsp and if not they will be redirected to appDashboard.jsp. How can I do this?



The data for FIRST_TIME in database inserted as yes during registration. Below are my codes.



appLogin.jsp



<!-- Form Module-->
<div class="module form-module">
<div class="toggle"><i class="fa fa-times fa-pencil"></i>
<div class="tooltip" style=" margin-right: -110px;">Not a member? <a href="appRegister.jsp" style="color: gray">Register Here</a></div>
</div>
<!-- LOGIN FORM-->
<div class="form">
<h2>Login to your account</h2>
<form action="AppLogin">
<input type="text" placeholder="Username" name="appusername"/>
<input type="password" placeholder="Password" name="apppassword"/>
<button type="submit" name="login">Login</button>
</form>
</div>
<div class="cta"><a href="forgotPassword.jsp">Forgot your password?</a></div>
</div>


ApplicantLoginServlet.java



protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
ApplicantBean applicant = new ApplicantBean();
applicant.setUsername(request.getParameter("appusername"));
applicant.setPassword(request.getParameter("apppassword"));

applicant = ApplicantDA.Login(applicant);

if(applicant.isValid()) {
HttpSession session = request.getSession(true); //creating session
session.setAttribute("currentApplicant", applicant);
PrintWriter out = response.getWriter();

String firstTime = applicant.getFirstTime();
if(firstTime == "yes" ) {
System.out.println("ft " + firstTime);
response.setContentType("text/html");
response.setContentType("text/html");
out.println("<script type="text/javascript">");
out.println("alert('Successfully Logged In.');");
out.println("window.location= "appSetup.jsp"");
out.println("</script>");
}
else {
response.setContentType("text/html");
response.setContentType("text/html");
out.println("<script type="text/javascript">");
out.println("alert('Successfully Logged In.');");
out.println("window.location= "appDashboard.jsp"");
out.println("</script>");
}
}
else {
PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println("<script type="text/javascript">");
out.println("alert('Sorry, invalid username or password.');");
out.println("window.location= "appLogin.jsp"");
out.println("</script>");

//response.sendRedirect("InvalidLogin.jsp");
}
}
catch (Throwable theException) {
System.out.println(theException);
}
}


ApplicantDA.java



public static ApplicantBean Login(ApplicantBean bean) { //ApplicantLoginServlet line 24.
//preparing some objects for connection
Statement stmt = null;

String username = bean.getUsername();
String password = bean.getPassword();

String searchQuery = "SELECT * FROM APPLICANT WHERE APPLICANT_USERNAME='" + username + "'AND APPLICANT_PASSWORD='" + password + "'";

//"System.out.println" prints in the console; Normally used to trace the process
System.out.println("Your username is " + username);
System.out.println("Your password is " + password);
System.out.println("Query : " + searchQuery);

try {
//Connect to DB
currentCon = ConnectionManager.getConnection();
stmt = currentCon.createStatement();
rs = stmt.executeQuery(searchQuery);
boolean more = rs.next();

if(!more) {
System.out.println("Sorry, you are not a registered user! Please sign up first.");
bean.setValid(false);
}
else if(more) {
String fullname = rs.getString("APPLICANT_FULLNAME");
String email = rs.getString("APPLICANT_EMAIL");
String image = rs.getString("APPLICANT_IMAGE");
String firstTime = rs.getString("FIRST_TIME");
System.out.println("Welcome " + fullname);
System.out.println("Email : " + email);
System.out.println("Image : " + image);
System.out.println("First Time : " + firstTime);
bean.setFullname(fullname);
bean.setEmail(email);
bean.setImage(image);
bean.setValid(true);
}
}
catch(Exception ex) {
System.out.println("Login failed: An Exception has occured! " + ex);
}

//some exception handling
finally {
if(rs != null) {
try {
rs.close();
}
catch(Exception e) {
}
rs = null;
}
if(stmt != null) {
try {
stmt.close();
}
catch(Exception e) {
}
stmt = null;
}
if(currentCon != null) {
try {
currentCon.close();
}
catch(Exception e) {
}
currentCon = null;
}
}
return bean;
}


ApplicantBean.java



public class ApplicantBean {
private String fullname;
private String username;
private String email;
private String password;
private String image;
private String firstTime;
public boolean valid;

public String getFullname() { return fullname; }
public String getUsername() { return username; }
public String getEmail() { return email; }
public String getPassword() { return password; }
public String getImage() { return image; }
public String getFirstTime() { return firstTime; }

public void setFullname(String newFullname) {
fullname = newFullname;
}

public void setUsername(String newUsername) {
username = newUsername;
}

public void setEmail(String newEmail) {
email = newEmail;
}

public void setPassword(String newPassword) {
password = newPassword;
}

public void setImage(String newImage) {
image = newImage;
}

public void setFirstTime(String newFirstTime) {
firstTime = newFirstTime;
}

public boolean isValid() {
return valid;
}

public void setValid(boolean newValid) {
valid = newValid;
}
}


This is my first time learning servlet. Thankyou in advance!










share|improve this question


















  • 1





    Strings are not compared using == instead use equals or equalsIgnoreCase. Change your code if(firstTime == "yes" ) { to if("yes".equalsIgnoreCase(firstTime) ) {

    – Pushpesh Kumar Rajwanshi
    Nov 24 '18 at 10:21











  • @PushpeshKumarRajwanshi I've changed to if("yes".equalsIgnoreCase(firstTime) ) but nothing happens so I changed to if(firstTime.equalsIgnoreCase("yes") ) and eclipse gives me error java.lang.NullPointerException. How to I retreive selected data from ApplicantDA.java to ApplicantLoginServlet.java?

    – Nabella
    Nov 24 '18 at 10:44






  • 2





    System.out.println("First Time : " + firstTime); You print the value but do not set it on the bean.

    – Alan Hay
    Nov 24 '18 at 10:56











  • @AlanHay oh I got it thankyou!!

    – Nabella
    Nov 24 '18 at 11:10
















1















I need help with redirecting to different page after login.

I manage to do normal login redirect to appDashboard.jsp however, what I'm trying to do is if the user first-time login into the system then they will be redirected to appSetup.jsp and if not they will be redirected to appDashboard.jsp. How can I do this?



The data for FIRST_TIME in database inserted as yes during registration. Below are my codes.



appLogin.jsp



<!-- Form Module-->
<div class="module form-module">
<div class="toggle"><i class="fa fa-times fa-pencil"></i>
<div class="tooltip" style=" margin-right: -110px;">Not a member? <a href="appRegister.jsp" style="color: gray">Register Here</a></div>
</div>
<!-- LOGIN FORM-->
<div class="form">
<h2>Login to your account</h2>
<form action="AppLogin">
<input type="text" placeholder="Username" name="appusername"/>
<input type="password" placeholder="Password" name="apppassword"/>
<button type="submit" name="login">Login</button>
</form>
</div>
<div class="cta"><a href="forgotPassword.jsp">Forgot your password?</a></div>
</div>


ApplicantLoginServlet.java



protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
ApplicantBean applicant = new ApplicantBean();
applicant.setUsername(request.getParameter("appusername"));
applicant.setPassword(request.getParameter("apppassword"));

applicant = ApplicantDA.Login(applicant);

if(applicant.isValid()) {
HttpSession session = request.getSession(true); //creating session
session.setAttribute("currentApplicant", applicant);
PrintWriter out = response.getWriter();

String firstTime = applicant.getFirstTime();
if(firstTime == "yes" ) {
System.out.println("ft " + firstTime);
response.setContentType("text/html");
response.setContentType("text/html");
out.println("<script type="text/javascript">");
out.println("alert('Successfully Logged In.');");
out.println("window.location= "appSetup.jsp"");
out.println("</script>");
}
else {
response.setContentType("text/html");
response.setContentType("text/html");
out.println("<script type="text/javascript">");
out.println("alert('Successfully Logged In.');");
out.println("window.location= "appDashboard.jsp"");
out.println("</script>");
}
}
else {
PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println("<script type="text/javascript">");
out.println("alert('Sorry, invalid username or password.');");
out.println("window.location= "appLogin.jsp"");
out.println("</script>");

//response.sendRedirect("InvalidLogin.jsp");
}
}
catch (Throwable theException) {
System.out.println(theException);
}
}


ApplicantDA.java



public static ApplicantBean Login(ApplicantBean bean) { //ApplicantLoginServlet line 24.
//preparing some objects for connection
Statement stmt = null;

String username = bean.getUsername();
String password = bean.getPassword();

String searchQuery = "SELECT * FROM APPLICANT WHERE APPLICANT_USERNAME='" + username + "'AND APPLICANT_PASSWORD='" + password + "'";

//"System.out.println" prints in the console; Normally used to trace the process
System.out.println("Your username is " + username);
System.out.println("Your password is " + password);
System.out.println("Query : " + searchQuery);

try {
//Connect to DB
currentCon = ConnectionManager.getConnection();
stmt = currentCon.createStatement();
rs = stmt.executeQuery(searchQuery);
boolean more = rs.next();

if(!more) {
System.out.println("Sorry, you are not a registered user! Please sign up first.");
bean.setValid(false);
}
else if(more) {
String fullname = rs.getString("APPLICANT_FULLNAME");
String email = rs.getString("APPLICANT_EMAIL");
String image = rs.getString("APPLICANT_IMAGE");
String firstTime = rs.getString("FIRST_TIME");
System.out.println("Welcome " + fullname);
System.out.println("Email : " + email);
System.out.println("Image : " + image);
System.out.println("First Time : " + firstTime);
bean.setFullname(fullname);
bean.setEmail(email);
bean.setImage(image);
bean.setValid(true);
}
}
catch(Exception ex) {
System.out.println("Login failed: An Exception has occured! " + ex);
}

//some exception handling
finally {
if(rs != null) {
try {
rs.close();
}
catch(Exception e) {
}
rs = null;
}
if(stmt != null) {
try {
stmt.close();
}
catch(Exception e) {
}
stmt = null;
}
if(currentCon != null) {
try {
currentCon.close();
}
catch(Exception e) {
}
currentCon = null;
}
}
return bean;
}


ApplicantBean.java



public class ApplicantBean {
private String fullname;
private String username;
private String email;
private String password;
private String image;
private String firstTime;
public boolean valid;

public String getFullname() { return fullname; }
public String getUsername() { return username; }
public String getEmail() { return email; }
public String getPassword() { return password; }
public String getImage() { return image; }
public String getFirstTime() { return firstTime; }

public void setFullname(String newFullname) {
fullname = newFullname;
}

public void setUsername(String newUsername) {
username = newUsername;
}

public void setEmail(String newEmail) {
email = newEmail;
}

public void setPassword(String newPassword) {
password = newPassword;
}

public void setImage(String newImage) {
image = newImage;
}

public void setFirstTime(String newFirstTime) {
firstTime = newFirstTime;
}

public boolean isValid() {
return valid;
}

public void setValid(boolean newValid) {
valid = newValid;
}
}


This is my first time learning servlet. Thankyou in advance!










share|improve this question


















  • 1





    Strings are not compared using == instead use equals or equalsIgnoreCase. Change your code if(firstTime == "yes" ) { to if("yes".equalsIgnoreCase(firstTime) ) {

    – Pushpesh Kumar Rajwanshi
    Nov 24 '18 at 10:21











  • @PushpeshKumarRajwanshi I've changed to if("yes".equalsIgnoreCase(firstTime) ) but nothing happens so I changed to if(firstTime.equalsIgnoreCase("yes") ) and eclipse gives me error java.lang.NullPointerException. How to I retreive selected data from ApplicantDA.java to ApplicantLoginServlet.java?

    – Nabella
    Nov 24 '18 at 10:44






  • 2





    System.out.println("First Time : " + firstTime); You print the value but do not set it on the bean.

    – Alan Hay
    Nov 24 '18 at 10:56











  • @AlanHay oh I got it thankyou!!

    – Nabella
    Nov 24 '18 at 11:10














1












1








1








I need help with redirecting to different page after login.

I manage to do normal login redirect to appDashboard.jsp however, what I'm trying to do is if the user first-time login into the system then they will be redirected to appSetup.jsp and if not they will be redirected to appDashboard.jsp. How can I do this?



The data for FIRST_TIME in database inserted as yes during registration. Below are my codes.



appLogin.jsp



<!-- Form Module-->
<div class="module form-module">
<div class="toggle"><i class="fa fa-times fa-pencil"></i>
<div class="tooltip" style=" margin-right: -110px;">Not a member? <a href="appRegister.jsp" style="color: gray">Register Here</a></div>
</div>
<!-- LOGIN FORM-->
<div class="form">
<h2>Login to your account</h2>
<form action="AppLogin">
<input type="text" placeholder="Username" name="appusername"/>
<input type="password" placeholder="Password" name="apppassword"/>
<button type="submit" name="login">Login</button>
</form>
</div>
<div class="cta"><a href="forgotPassword.jsp">Forgot your password?</a></div>
</div>


ApplicantLoginServlet.java



protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
ApplicantBean applicant = new ApplicantBean();
applicant.setUsername(request.getParameter("appusername"));
applicant.setPassword(request.getParameter("apppassword"));

applicant = ApplicantDA.Login(applicant);

if(applicant.isValid()) {
HttpSession session = request.getSession(true); //creating session
session.setAttribute("currentApplicant", applicant);
PrintWriter out = response.getWriter();

String firstTime = applicant.getFirstTime();
if(firstTime == "yes" ) {
System.out.println("ft " + firstTime);
response.setContentType("text/html");
response.setContentType("text/html");
out.println("<script type="text/javascript">");
out.println("alert('Successfully Logged In.');");
out.println("window.location= "appSetup.jsp"");
out.println("</script>");
}
else {
response.setContentType("text/html");
response.setContentType("text/html");
out.println("<script type="text/javascript">");
out.println("alert('Successfully Logged In.');");
out.println("window.location= "appDashboard.jsp"");
out.println("</script>");
}
}
else {
PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println("<script type="text/javascript">");
out.println("alert('Sorry, invalid username or password.');");
out.println("window.location= "appLogin.jsp"");
out.println("</script>");

//response.sendRedirect("InvalidLogin.jsp");
}
}
catch (Throwable theException) {
System.out.println(theException);
}
}


ApplicantDA.java



public static ApplicantBean Login(ApplicantBean bean) { //ApplicantLoginServlet line 24.
//preparing some objects for connection
Statement stmt = null;

String username = bean.getUsername();
String password = bean.getPassword();

String searchQuery = "SELECT * FROM APPLICANT WHERE APPLICANT_USERNAME='" + username + "'AND APPLICANT_PASSWORD='" + password + "'";

//"System.out.println" prints in the console; Normally used to trace the process
System.out.println("Your username is " + username);
System.out.println("Your password is " + password);
System.out.println("Query : " + searchQuery);

try {
//Connect to DB
currentCon = ConnectionManager.getConnection();
stmt = currentCon.createStatement();
rs = stmt.executeQuery(searchQuery);
boolean more = rs.next();

if(!more) {
System.out.println("Sorry, you are not a registered user! Please sign up first.");
bean.setValid(false);
}
else if(more) {
String fullname = rs.getString("APPLICANT_FULLNAME");
String email = rs.getString("APPLICANT_EMAIL");
String image = rs.getString("APPLICANT_IMAGE");
String firstTime = rs.getString("FIRST_TIME");
System.out.println("Welcome " + fullname);
System.out.println("Email : " + email);
System.out.println("Image : " + image);
System.out.println("First Time : " + firstTime);
bean.setFullname(fullname);
bean.setEmail(email);
bean.setImage(image);
bean.setValid(true);
}
}
catch(Exception ex) {
System.out.println("Login failed: An Exception has occured! " + ex);
}

//some exception handling
finally {
if(rs != null) {
try {
rs.close();
}
catch(Exception e) {
}
rs = null;
}
if(stmt != null) {
try {
stmt.close();
}
catch(Exception e) {
}
stmt = null;
}
if(currentCon != null) {
try {
currentCon.close();
}
catch(Exception e) {
}
currentCon = null;
}
}
return bean;
}


ApplicantBean.java



public class ApplicantBean {
private String fullname;
private String username;
private String email;
private String password;
private String image;
private String firstTime;
public boolean valid;

public String getFullname() { return fullname; }
public String getUsername() { return username; }
public String getEmail() { return email; }
public String getPassword() { return password; }
public String getImage() { return image; }
public String getFirstTime() { return firstTime; }

public void setFullname(String newFullname) {
fullname = newFullname;
}

public void setUsername(String newUsername) {
username = newUsername;
}

public void setEmail(String newEmail) {
email = newEmail;
}

public void setPassword(String newPassword) {
password = newPassword;
}

public void setImage(String newImage) {
image = newImage;
}

public void setFirstTime(String newFirstTime) {
firstTime = newFirstTime;
}

public boolean isValid() {
return valid;
}

public void setValid(boolean newValid) {
valid = newValid;
}
}


This is my first time learning servlet. Thankyou in advance!










share|improve this question














I need help with redirecting to different page after login.

I manage to do normal login redirect to appDashboard.jsp however, what I'm trying to do is if the user first-time login into the system then they will be redirected to appSetup.jsp and if not they will be redirected to appDashboard.jsp. How can I do this?



The data for FIRST_TIME in database inserted as yes during registration. Below are my codes.



appLogin.jsp



<!-- Form Module-->
<div class="module form-module">
<div class="toggle"><i class="fa fa-times fa-pencil"></i>
<div class="tooltip" style=" margin-right: -110px;">Not a member? <a href="appRegister.jsp" style="color: gray">Register Here</a></div>
</div>
<!-- LOGIN FORM-->
<div class="form">
<h2>Login to your account</h2>
<form action="AppLogin">
<input type="text" placeholder="Username" name="appusername"/>
<input type="password" placeholder="Password" name="apppassword"/>
<button type="submit" name="login">Login</button>
</form>
</div>
<div class="cta"><a href="forgotPassword.jsp">Forgot your password?</a></div>
</div>


ApplicantLoginServlet.java



protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
ApplicantBean applicant = new ApplicantBean();
applicant.setUsername(request.getParameter("appusername"));
applicant.setPassword(request.getParameter("apppassword"));

applicant = ApplicantDA.Login(applicant);

if(applicant.isValid()) {
HttpSession session = request.getSession(true); //creating session
session.setAttribute("currentApplicant", applicant);
PrintWriter out = response.getWriter();

String firstTime = applicant.getFirstTime();
if(firstTime == "yes" ) {
System.out.println("ft " + firstTime);
response.setContentType("text/html");
response.setContentType("text/html");
out.println("<script type="text/javascript">");
out.println("alert('Successfully Logged In.');");
out.println("window.location= "appSetup.jsp"");
out.println("</script>");
}
else {
response.setContentType("text/html");
response.setContentType("text/html");
out.println("<script type="text/javascript">");
out.println("alert('Successfully Logged In.');");
out.println("window.location= "appDashboard.jsp"");
out.println("</script>");
}
}
else {
PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println("<script type="text/javascript">");
out.println("alert('Sorry, invalid username or password.');");
out.println("window.location= "appLogin.jsp"");
out.println("</script>");

//response.sendRedirect("InvalidLogin.jsp");
}
}
catch (Throwable theException) {
System.out.println(theException);
}
}


ApplicantDA.java



public static ApplicantBean Login(ApplicantBean bean) { //ApplicantLoginServlet line 24.
//preparing some objects for connection
Statement stmt = null;

String username = bean.getUsername();
String password = bean.getPassword();

String searchQuery = "SELECT * FROM APPLICANT WHERE APPLICANT_USERNAME='" + username + "'AND APPLICANT_PASSWORD='" + password + "'";

//"System.out.println" prints in the console; Normally used to trace the process
System.out.println("Your username is " + username);
System.out.println("Your password is " + password);
System.out.println("Query : " + searchQuery);

try {
//Connect to DB
currentCon = ConnectionManager.getConnection();
stmt = currentCon.createStatement();
rs = stmt.executeQuery(searchQuery);
boolean more = rs.next();

if(!more) {
System.out.println("Sorry, you are not a registered user! Please sign up first.");
bean.setValid(false);
}
else if(more) {
String fullname = rs.getString("APPLICANT_FULLNAME");
String email = rs.getString("APPLICANT_EMAIL");
String image = rs.getString("APPLICANT_IMAGE");
String firstTime = rs.getString("FIRST_TIME");
System.out.println("Welcome " + fullname);
System.out.println("Email : " + email);
System.out.println("Image : " + image);
System.out.println("First Time : " + firstTime);
bean.setFullname(fullname);
bean.setEmail(email);
bean.setImage(image);
bean.setValid(true);
}
}
catch(Exception ex) {
System.out.println("Login failed: An Exception has occured! " + ex);
}

//some exception handling
finally {
if(rs != null) {
try {
rs.close();
}
catch(Exception e) {
}
rs = null;
}
if(stmt != null) {
try {
stmt.close();
}
catch(Exception e) {
}
stmt = null;
}
if(currentCon != null) {
try {
currentCon.close();
}
catch(Exception e) {
}
currentCon = null;
}
}
return bean;
}


ApplicantBean.java



public class ApplicantBean {
private String fullname;
private String username;
private String email;
private String password;
private String image;
private String firstTime;
public boolean valid;

public String getFullname() { return fullname; }
public String getUsername() { return username; }
public String getEmail() { return email; }
public String getPassword() { return password; }
public String getImage() { return image; }
public String getFirstTime() { return firstTime; }

public void setFullname(String newFullname) {
fullname = newFullname;
}

public void setUsername(String newUsername) {
username = newUsername;
}

public void setEmail(String newEmail) {
email = newEmail;
}

public void setPassword(String newPassword) {
password = newPassword;
}

public void setImage(String newImage) {
image = newImage;
}

public void setFirstTime(String newFirstTime) {
firstTime = newFirstTime;
}

public boolean isValid() {
return valid;
}

public void setValid(boolean newValid) {
valid = newValid;
}
}


This is my first time learning servlet. Thankyou in advance!







java jsp servlets






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 10:16









NabellaNabella

178




178








  • 1





    Strings are not compared using == instead use equals or equalsIgnoreCase. Change your code if(firstTime == "yes" ) { to if("yes".equalsIgnoreCase(firstTime) ) {

    – Pushpesh Kumar Rajwanshi
    Nov 24 '18 at 10:21











  • @PushpeshKumarRajwanshi I've changed to if("yes".equalsIgnoreCase(firstTime) ) but nothing happens so I changed to if(firstTime.equalsIgnoreCase("yes") ) and eclipse gives me error java.lang.NullPointerException. How to I retreive selected data from ApplicantDA.java to ApplicantLoginServlet.java?

    – Nabella
    Nov 24 '18 at 10:44






  • 2





    System.out.println("First Time : " + firstTime); You print the value but do not set it on the bean.

    – Alan Hay
    Nov 24 '18 at 10:56











  • @AlanHay oh I got it thankyou!!

    – Nabella
    Nov 24 '18 at 11:10














  • 1





    Strings are not compared using == instead use equals or equalsIgnoreCase. Change your code if(firstTime == "yes" ) { to if("yes".equalsIgnoreCase(firstTime) ) {

    – Pushpesh Kumar Rajwanshi
    Nov 24 '18 at 10:21











  • @PushpeshKumarRajwanshi I've changed to if("yes".equalsIgnoreCase(firstTime) ) but nothing happens so I changed to if(firstTime.equalsIgnoreCase("yes") ) and eclipse gives me error java.lang.NullPointerException. How to I retreive selected data from ApplicantDA.java to ApplicantLoginServlet.java?

    – Nabella
    Nov 24 '18 at 10:44






  • 2





    System.out.println("First Time : " + firstTime); You print the value but do not set it on the bean.

    – Alan Hay
    Nov 24 '18 at 10:56











  • @AlanHay oh I got it thankyou!!

    – Nabella
    Nov 24 '18 at 11:10








1




1





Strings are not compared using == instead use equals or equalsIgnoreCase. Change your code if(firstTime == "yes" ) { to if("yes".equalsIgnoreCase(firstTime) ) {

– Pushpesh Kumar Rajwanshi
Nov 24 '18 at 10:21





Strings are not compared using == instead use equals or equalsIgnoreCase. Change your code if(firstTime == "yes" ) { to if("yes".equalsIgnoreCase(firstTime) ) {

– Pushpesh Kumar Rajwanshi
Nov 24 '18 at 10:21













@PushpeshKumarRajwanshi I've changed to if("yes".equalsIgnoreCase(firstTime) ) but nothing happens so I changed to if(firstTime.equalsIgnoreCase("yes") ) and eclipse gives me error java.lang.NullPointerException. How to I retreive selected data from ApplicantDA.java to ApplicantLoginServlet.java?

– Nabella
Nov 24 '18 at 10:44





@PushpeshKumarRajwanshi I've changed to if("yes".equalsIgnoreCase(firstTime) ) but nothing happens so I changed to if(firstTime.equalsIgnoreCase("yes") ) and eclipse gives me error java.lang.NullPointerException. How to I retreive selected data from ApplicantDA.java to ApplicantLoginServlet.java?

– Nabella
Nov 24 '18 at 10:44




2




2





System.out.println("First Time : " + firstTime); You print the value but do not set it on the bean.

– Alan Hay
Nov 24 '18 at 10:56





System.out.println("First Time : " + firstTime); You print the value but do not set it on the bean.

– Alan Hay
Nov 24 '18 at 10:56













@AlanHay oh I got it thankyou!!

– Nabella
Nov 24 '18 at 11:10





@AlanHay oh I got it thankyou!!

– Nabella
Nov 24 '18 at 11:10












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457150%2fservlet-login-redirect-to-different-jsp%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457150%2fservlet-login-redirect-to-different-jsp%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen