github.com/ismailbayram/bigpicture@v0.0.0-20231225173155-e4b21f5efcff/internal/browser/javaproject/src/main/com/shashi/servlets/UserLoginServlet.java (about) 1 package com.shashi.servlets; 2 3 import java.io.IOException; 4 import java.io.PrintWriter; 5 6 import javax.servlet.RequestDispatcher; 7 import javax.servlet.ServletException; 8 import javax.servlet.annotation.WebServlet; 9 import javax.servlet.http.HttpServlet; 10 import javax.servlet.http.HttpServletRequest; 11 import javax.servlet.http.HttpServletResponse; 12 13 import com.shashi.constant.ResponseCode; 14 import com.shashi.constant.UserRole; 15 import com.shashi.utility.TrainUtil; 16 17 @WebServlet("/userlogin") 18 public class UserLoginServlet extends HttpServlet { 19 /** 20 * 21 */ 22 private static final long serialVersionUID = 1L; 23 24 protected void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 25 PrintWriter pw = res.getWriter(); 26 res.setContentType("text/html"); 27 String uName = req.getParameter("uname"); 28 String pWord = req.getParameter("pword"); 29 30 String responseMsg = TrainUtil.login(req, res, UserRole.CUSTOMER, uName, pWord); 31 if (ResponseCode.SUCCESS.toString().equalsIgnoreCase(responseMsg)) { 32 RequestDispatcher rd = req.getRequestDispatcher("UserHome.html"); 33 rd.include(req, res); 34 pw.println("<div class='main'><p1 class='menu'>Hello " + uName 35 + " ! Welcome to our new NITRTC Website</p1></div>"); 36 pw.println("<div class='tab'>Hello " + uName 37 + " ! Good to See You here.<br/> Here you can Check up the train " 38 + "details and train schedule,fare Enquiry and many more information.<br/>Just go to the Side Menu Links and " 39 + "Explore the Advantages.<br/><br/>Thanks For Being Connected with us!" + "</div>"); 40 41 } else { 42 RequestDispatcher rd = req.getRequestDispatcher("UserLogin.html"); 43 rd.include(req, res); 44 45 pw.println("<div class='tab'><p1 class='menu'>" + responseMsg + "</p1></div>"); 46 47 } 48 49 } 50 51 }