Mini-Project - Servlet, JSP Hands-On Solution | TCS Fresco Play
Disclaimer: The primary purpose of providing this solution is to assist and support anyone who are unable to complete these courses due to a technical issue or a lack of expertise. This website's information or data are solely for the purpose of knowledge and education.
Make an effort to understand these solutions and apply them to your Hands-On difficulties. (It is not advisable that copy and paste these solutions).>
All Question of the MCQs Present Below for Ease Use Ctrl + F with the question name to find the Question. All the Best!
Mini-Project - Servlet, JSP Hands-On Solution
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");
}
}
**************************************************Credit for the above notes, goes to the respective owners.If you have any queries, please feel free to ask on the comment section.If you want MCQs and Hands-On solutions for any courses, Please feel free to ask on the comment section too.Please share and support our page!
Post a Comment