github.com/ismailbayram/bigpicture@v0.0.0-20231225173155-e4b21f5efcff/internal/browser/javaproject/src/main/com/shashi/servlets/AdminLogin.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.beans.TrainException; 14 import com.shashi.constant.UserRole; 15 import com.shashi.utility.TrainUtil; 16 17 @SuppressWarnings("serial") 18 @WebServlet("/adminlogin") 19 public class AdminLogin extends HttpServlet { 20 21 /** 22 * 23 * @param req 24 * @param res 25 * @throws IOException 26 * @throws ServletException 27 */ 28 protected void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { 29 PrintWriter pw = res.getWriter(); 30 res.setContentType("text/html"); 31 String uName = req.getParameter("uname"); 32 String pWord = req.getParameter("pword"); 33 try { 34 String message = TrainUtil.login(req, res, UserRole.ADMIN, uName, pWord); 35 if ("SUCCESS".equalsIgnoreCase(message)) { 36 37 RequestDispatcher rd = req.getRequestDispatcher("AdminHome.html"); 38 rd.include(req, res); 39 pw.println("<div class='main'><p1 class='menu'>Hello, " + uName + " ! Welcome </p1></div>"); 40 pw.println("<div class='tab'>Hi ! Here You can Manage Train Information as per Your Requirement</div>"); 41 42 } else { 43 RequestDispatcher rd = req.getRequestDispatcher("AdminLogin.html"); 44 rd.include(req, res); 45 pw.println("<div class='tab'><p1 class='menu'>" + message + "</p1></div>"); 46 47 } 48 } catch (Exception e) { 49 throw new TrainException(422, this.getClass().getName() + "_FAILED", e.getMessage()); 50 } 51 } 52 }