test
Форк от lirfrnk/test
1package servlets;
2
3import java.io.IOException;
4import java.io.PrintWriter;
5
6import javax.servlet.RequestDispatcher;
7import javax.servlet.ServletException;
8import javax.servlet.http.HttpServlet;
9import javax.servlet.http.HttpServletRequest;
10import javax.servlet.http.HttpServletResponse;
11
12import com.bittercode.model.UserRole;
13import com.bittercode.util.StoreUtil;
14//Http Servlet extended class for showing the about information
15public class AboutServlet extends HttpServlet {
16
17public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
18PrintWriter pw = res.getWriter();
19res.setContentType("text/html");
20//If the store is logged in as customer or seller show about info
21if (StoreUtil.isLoggedIn(UserRole.CUSTOMER, req.getSession())) {
22RequestDispatcher rd = req.getRequestDispatcher("CustomerHome.html");
23rd.include(req, res);
24StoreUtil.setActiveTab(pw, "about");
25pw.println("<iframe src=\"https://flowcv.me/shashirajraja\" class=\"holds-the-iframe\"\r\n"
26+ " title=\"My Personal Website\" width=\"100%\" height=\"100%\"></iframe>");
27
28} else if (StoreUtil.isLoggedIn(UserRole.SELLER, req.getSession())) {
29RequestDispatcher rd = req.getRequestDispatcher("SellerHome.html");
30rd.include(req, res);
31StoreUtil.setActiveTab(pw, "about");
32pw.println("<iframe src=\"https://flowcv.me/shashirajraja\" class=\"holds-the-iframe\"\r\n"
33+ " title=\"My Personal Website\" width=\"100%\" height=\"100%\"></iframe>");
34
35} else {
36//If the user is not logged in, ask to login first
37//Proceed only if logged in or forword to login page
38RequestDispatcher rd = req.getRequestDispatcher("login.html");
39rd.include(req, res);
40pw.println("<table class=\"tab\"><tr><td>Please Login First to Continue!!</td></tr></table>");
41}
42
43}
44
45}
46