> Mini-Project - Servlet, JSP Hands-On Solution - TECH UPDATE

Mini-Project - Servlet, JSP Hands-On Solution

 Mini-Project - Servlet, JSP Hands-On Solution


These Hands-On Solutions is only for Learning Purpose. Please utilize the service and learn the technology. 

The Course Id of the Hands-On is 63718


1. LoginServlet.java:- 

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/Login")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// your code here
    String email = request.getParameter("email");
    String password = request.getParameter("password");
    boolean validated = Validate.checkUser(email, password);
    PrintWriter writer = response.getWriter();
    if(validated){
    RequestDispatcher dispatcher = request.getRequestDispatcher("Welcome");
    dispatcher.forward(request, response);
    }else{
      writer.write("Username or Password incorrect");
    }
}

}

2. WelcomeServlet.java:- 

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/Welcome")
public class WelcomeServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
    //your code here
    PrintWriter writer = response.getWriter();
    writer.write("Welcome user");

}
}



Mini-Project - Servlet, JSP Hands-On Solution Mini-Project - Servlet, JSP Hands-On Solution Reviewed by TECH UPDATE on December 31, 2021 Rating: 5

17 comments:

  1. How to run project means correct command

    ReplyDelete
    Replies
    1. Please add the terminal command also

      Delete
    2. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project LoginWebApp: Compilation failure
      [ERROR] /home/labuser/Desktop/Project/mvc-jsp-servlet/LoginWebApp/src/main/java/com/fresco/login/LoginServlet.java:[19,25] cannot find symbol
      [ERROR] symbol: variable Validate
      [ERROR] location: class LoginServlet
      [ERROR] -> [Help 1]

      Delete
  2. symbol is not found error is coming

    write

    ReplyDelete
  3. cannot find symbol

    variable write error is coming

    ReplyDelete
  4. How to create problem_statement.html page. I'm not getting this. Please help me.

    ReplyDelete
  5. Please tell me how to create problem_statement.html page. Because I referred the photo but I'm not getting how to create this page.

    ReplyDelete
  6. Getting error main method missing

    ReplyDelete
  7. The code is not working

    ReplyDelete
  8. What is the command to run project

    ReplyDelete
  9. After running it is showing can't open install. Sh

    ReplyDelete
  10. How to run this project pls explain me

    ReplyDelete
  11. bro i am getting cannot find symbol validate in the loginservlet.java error what to do please help.

    ReplyDelete
  12. Please update 63717 course

    ReplyDelete
  13. i am getting an error while running this please help the error is :-[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/labuser/Desktop/Project/mvc-jsp-servlet). Please verify you invoked Maven from the correct directory. -> [Help 1]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
    PLEASE HELP ME to fix this

    ReplyDelete

Powered by Blogger.