java > com\project > db > DBConnection.
java
package [Link];
import [Link];
import [Link];
public class DBConnection {
private static final String URL = "jdbc:mysql://localhost:3306/skincare";
private static final String USER = "root"; // MySQL username
private static final String PASSWORD = "root"; // MySQL password
public static Connection getConnection() {
try {
[Link]("[Link]");
return [Link](URL, USER, PASSWORD);
} catch (Exception e) {
[Link]();
return null;
}
}
}
>util >[Link]
package [Link];
import [Link];
import [Link].*;
import [Link].*;
public class EmailSender {
private static final String USER = "";
private static final String PASSWORD = " ";
public static boolean sendEmail(String to, String subject, String body) {
Properties props = new Properties();
[Link]("[Link]", "[Link]");
[Link]("[Link]", "587");
[Link]("[Link]", "true");
[Link]("[Link]", "true");
Session session = [Link](props,
new [Link]() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(USER, PASSWORD);
}
});
try {
Message message = new MimeMessage(session);
g tF ( I t tAdd (USER))
g g g
[Link](new InternetAddress(USER));
[Link]([Link], [Link](to));
[Link](subject);
[Link](body);
[Link](message);
return true;
} catch (Exception e) {
[Link]();
return false;
}
}
}
>[Link]
package [Link];
import [Link];
public class OTPGenerator {
public static String generateOTP() {
Random random = new Random();
int otp = 100000 + [Link](900000); // 6-digit OTP
return [Link](otp);
}
}
>[Link]
package [Link];
import [Link];
public class PasswordUtils {
// Hash password
public static String hashPassword(String plainTextPassword) {
return [Link](plainTextPassword, [Link](12));
}
// Verify password
public static boolean checkPassword(String plainPassword, String hashedPassword) {
return [Link](plainPassword, hashedPassword);
}
}
>web > [Link]
package [Link];
import [Link];
i tj k t l t*
p p j p ;
import [Link].*;
import [Link];
import [Link].*;
import [Link];
@WebServlet("/addToCart")
public class AddToCartServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
private final CartDAO cartDAO = new CartDAO();
// put this at the top of doPost for 30 seconds
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
HttpSession session = [Link](false);
/* 1. Try session first */
Integer uid = (session != null) ? (Integer) [Link]("userUid") : null;
/* 2. Fallback to cookie if session is dead */
if (uid == null) {
Cookie[] cookies = [Link]();
if (cookies != null) {
for (Cookie c : cookies) {
if ("userUid".equals([Link]())) {
try {
uid = [Link]([Link]());
} catch (NumberFormatException ignore) {}
break;
}
}
}
}
/* 3. Not logged-in → 401 */
if (uid == null) {
[Link](HttpServletResponse.SC_UNAUTHORIZED);
[Link]().write("{\"status\":\"error\",\"message\":\"Please log in first\"}");
return;
}
/* 4. Parse product id and quantity (default 1) */
int pid;
i t t 1
int qty = 1;
try {
pid = [Link]([Link]("pid"));
String q = [Link]("qty");
if (q != null) qty = [Link](q);
if (qty <= 0) throw new NumberFormatException();
} catch (NumberFormatException ex) {
[Link](HttpServletResponse.SC_BAD_REQUEST);
[Link]().write("{\"status\":\"error\",\"message\":\"Invalid parameters\"}");
return;
}
/* 5. Update cart */
int currentQty = [Link](uid, pid);
[Link](uid, pid, currentQty + qty);
/* 6. Respond JSON */
[Link]("application/json");
[Link]().write("{\"status\":\"success\",\"newQty\":" + (currentQty + qty) + "}");
}
}
[Link]
package [Link];
import [Link].*;
import [Link].*;
import [Link].*;
import [Link];
import [Link];
public class BatchOrderServlet extends HttpServlet {
private final CartDAO cartDAO = new CartDAO();
private final OrderDAO orderDAO = new OrderDAO();
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
HttpSession session = [Link](false);
Integer uid = (session != null) ? (Integer) [Link]("userUid") : null;
if (uid == null) {
[Link]("[Link]");
return;
}
String address = [Link]("address");
St i g h g tP t (" h ")
String phone = [Link]("phone");
List<CartItem> items = [Link](uid);
if ([Link]()) {
[Link]("[Link]");
return;
}
int total = [Link]()
.mapToInt(ci -> [Link]() * [Link]())
.sum();
try {
int oid = [Link](uid, address, phone, total);
for (CartItem ci : items) {
[Link](oid, [Link](), [Link](), [Link]());
}
[Link](uid);
[Link]("latestOrderId", oid);
[Link]("[Link]");
} catch (Exception e) {
throw new ServletException(e);
}
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link].*;
import [Link].*;
import [Link];
import [Link];
public class ConfirmOrderServlet extends HttpServlet {
private final OrderDAO orderDAO = new OrderDAO();
private final CartDAO cartDAO = new CartDAO();
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
HttpSession session = [Link](false);
Integer uid = (session != null) ? (Integer) [Link]("userUid") : null;
if (uid == null) {
dR di t("l gi j ")
[Link]("[Link]");
return;
}
int pid = [Link]([Link]("pid"));
int qty = [Link]([Link]("qty"));
String address = [Link]("address");
String phone = [Link]("phone");
int price = [Link](pid); // you can also pass price from JSP
int total = price * qty;
try {
int oid = [Link](uid, address, phone, total);
[Link](oid, pid, qty, price);
[Link]("latestOrderId", oid);
[Link]("[Link]");
} catch (SQLException e) {
throw new ServletException(e);
}
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link].*;
import [Link].*;
import [Link].*;
public class DisplayPhotoServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
HttpSession session = [Link]();
String email = (String) [Link]("userEmail");
if(email == null) {
[Link]("[Link]");
return;
}
try (Connection conn = [Link]()) {
PreparedStatement ps = [Link]("SELECT photo FROM user WHERE
email_phone=?");
[Link](1, email);
ResultSet rs = [Link]();
if([Link]() && [Link]("photo") != null){
b t [] h t B t g tB t (" h t ")
byte[] photoBytes = [Link]("photo");
[Link]("image/jpeg"); // or "image/png" depending on stored type
[Link]().write(photoBytes);
} else {
// default avatar
[Link]("images/[Link]");
}
} catch (Exception e) {
[Link]();
}
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link].*;
import [Link].*;
import [Link];
public class ForgotpasswordSendOTPServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String email = [Link]("email");
// Generate OTP
String otp = [Link]();
long otpGeneratedTime = [Link](); // milliseconds
long otpValidDuration = 2 * 60 * 1000; // 2 mins in ms
// Save data + OTP info in session
HttpSession session = [Link]();
[Link]("email", email);
[Link]("otp", otp);
[Link]("otpTime", otpGeneratedTime);
[Link]("otpValidDuration", otpValidDuration);
[Link]("otpAttempts", 0);
// Send OTP via email
b l ilS t E ilS d dE il( il "Y OTP C d " "Y OTP i " t )
//
boolean emailSent = [Link](email, "Your OTP Code", "Your OTP is: " + otp);
if (emailSent) {
[Link]("[Link]");
} else {
[Link]().println("Failed to send OTP. Please try again.");
}
}
}
[Link]
package [Link];
import [Link].*;
import [Link].*;
import [Link];
public class ForgotpasswordVerifyOTPServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = [Link]();
String enteredOtp = [Link]("otp");
String sessionOtp = (String) [Link]("otp");
Long otpTime = (Long) [Link]("otpTime");
Long otpValidDuration = (Long) [Link]("otpValidDuration");
Integer attempts = (Integer) [Link]("otpAttempts");
if (attempts == null) attempts = 0;
[Link]("text/html;charset=UTF-8");
if (attempts >= 3) {
❌
[Link]().println("<script>alert(' Maximum OTP attempts reached. Please request a new
OTP.');[Link]='[Link]';</script>");
return;
}
attempts++;
[Link]("otpAttempts", attempts);
if (otpTime == null || ([Link]() - otpTime > otpValidDuration)) {
❌
[Link]().println("<script>alert(' OTP expired. Please request a new
OTP.');[Link]='[Link]';</script>");
return;
}
if (sessionOtp != null && [Link](enteredOtp)) {
// OTP verified successfully
[Link]("otp");
[Link]("otpTime");
i Att ib t (" t V lidD ti ")
[Link]("otpValidDuration");
[Link]("otpAttempts");
[Link]("forgotOtpVerified", true);
[Link]("forgotEmail", [Link]("email"));
[Link]("[Link]");
} else {
[Link]().println("<script>alert('
"');[Link]();</script>");
❌ Invalid OTP. Attempts left: " + (3 - attempts) +
}
}
}
[Link]
package [Link];
import [Link];
import [Link].*;
import [Link].*;
import [Link].*;
import [Link].*;
public class LoadMessagesServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
HttpSession session = [Link](false);
String myEmail = session==null?null:(String)[Link]("userEmail");
String other = [Link]("with");
[Link]("text/html;charset=UTF-8");
if(myEmail==null||other==null){ return; }
try(PrintWriter out=[Link]();
Connection con=[Link]();
PreparedStatement ps=[Link](
"SELECT sender_email,message,timestamp FROM messages " +
"WHERE (sender_email=? AND receiver_email=?) OR (sender_email=? AND receiver_email=?) " +
"ORDER BY timestamp ASC")) {
[Link](1,myEmail);
[Link](2,other);
[Link](3,other);
[Link](4,myEmail);
ResultSet rs=[Link]();
while([Link]()){
String s=[Link](1);
String m=[Link](2);
String t=[Link](3);
b l l ( E il)
g g g( );
boolean me=[Link](myEmail);
[Link]("<div class='bubble-row "+(me?"me":"other")+"'>");
[Link]("<div class='bubble "+(me?"me":"other")+"'>"+m+"</div>");
[Link]("</div>");
}
} catch(Exception e){ [Link](); }
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link].*;
import [Link].*;
import [Link];
import [Link].*;
public class LoginServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
String email = [Link]("email");
String password = [Link]("password");
String remember = [Link]("remember");
try (Connection conn = [Link]()) {
// ✅ uid ကိုပါ select လုပ်
PreparedStatement stmt = [Link]("SELECT uid, name, psd, role FROM user WHERE
email_phone=?");
[Link](1, email);
ResultSet rs = [Link]();
if([Link]()) {
int uid = [Link]("uid"); // ✅ uid ထည့်လိုက်ပြီ
String hashed = [Link]("psd");
String name = [Link]("name");
String role = [Link]("role");
if([Link](password, hashed)) {
HttpSession session = [Link]();
[Link]("userUid", uid); // ✅ uid ကို session ထဲထည့်
[Link]("userEmail", email);
[Link]("userName", name);
[Link]("userRole", role);
// Remember Me
if(" " l ( b )) {
//
if("on".equals(remember)) {
Cookie cookieEmail = new Cookie("userEmail", email);
Cookie cookieRole = new Cookie("userRole", role);
Cookie cookieUid = new Cookie("userUid", [Link](uid)); // ✅ uid cookie
[Link](60*60*24*30); // 30 days
[Link](60*60*24*30);
[Link](60*60*24*30);
[Link]("/");
[Link]("/");
[Link]("/");
[Link](cookieEmail);
[Link](cookieRole);
[Link](cookieUid);
}
// Redirect by role
if("ADMIN".equalsIgnoreCase(role)) {
[Link]("[Link]"); // admin
} else {
[Link]("[Link]"); // user
}
return;
}
}
[Link]("error", "Invalid email or password");
[Link]("[Link]").forward(request, response);
} catch(Exception e) {
[Link]();
[Link]("error", "Login error: " + [Link]());
[Link]("[Link]").forward(request, response);
}
}
}
[Link]
package [Link];
import [Link].*;
import [Link].*;
import [Link];
public class LogoutServlet extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
HttpSession session = [Link](false);
if( i ! ll) i i lid t ()
p q g ( );
if(session != null) [Link]();
Cookie cookie = new Cookie("userEmail", "");
[Link](0);
[Link]("/");
[Link](cookie);
[Link]("[Link]");
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link].*;
public class PhotoServlet extends HttpServlet {
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String email = [Link]("email");
if (email == null || [Link]()) { [Link](400); return; }
try (Connection con = [Link]();
PreparedStatement ps = [Link](
"SELECT photo FROM user WHERE email_phone=? LIMIT 1")) {
[Link](1, email);
try (ResultSet rs = [Link]()) {
if ([Link]()) {
byte[] img = [Link](1);
if (img != null && [Link] > 0) {
[Link]("image/jpeg"); // or detect
[Link]([Link]);
try (OutputStream os = [Link]()) { [Link](img); }
return;
}
}
}
} catch (Exception ignored) {}
// Fallback: 1x1 transparent gif
tC t tT ("i g /gif")
[Link]("image/gif");
[Link]().write(new byte[]{
0x47,0x49,0x46,0x38,0x39,0x61,1,0,1,0, (byte)0x80,0,0,0,0,0,(byte)0xFF,(byte)0xFF,(byte)0xFF,0,0,0,
0x21,(byte)0xF9,4,1,0,0,0,0x2C,0,0,0,0,1,0,1,0,0,2,2,0,1,0,0
});
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link].*;
import [Link].*;
import [Link];
import [Link];
import [Link];
public class ResetPasswordServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = [Link]();
Boolean otpVerified = (Boolean) [Link]("forgotOtpVerified");
String email = (String) [Link]("forgotEmail");
String newPassword = [Link]("password");
if (otpVerified != null && otpVerified && email != null) {
try (Connection conn = [Link]()) {
String sql = "UPDATE user SET psd=? WHERE email_phone=?";
PreparedStatement stmt = [Link](sql);
[Link](1, [Link](newPassword));
[Link](2, email);
int rows = [Link]();
[Link]("forgotOtpVerified");
[Link]("forgotEmail");
if (rows > 0) {
[Link]("[Link]?msg=Password+reset+successful");
} else {
[Link]().println(" ❌ No user found with that email.");
}
} catch (Exception e) {
[Link]();
[Link]().println("Error resetting password: " + [Link]());
}
p g () p ( gp g g ());
}
} else {
❌
[Link]().println("<h3> Session expired or OTP not verified. <a
href='[Link]'>Try again</a></h3>");
}
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link].*;
public class SendMessageServlet2 extends HttpServlet {
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = [Link](false);
String sender = session == null ? null : (String) [Link]("userEmail");
String receiver = [Link]("receiver");
String message = [Link]("message");
if (sender == null || receiver == null || [Link]() || message == null || [Link]().isEmpty()) {
[Link]("[Link]?with=" + (receiver==null?"":receiver));
return;
}
try (Connection con = [Link]();
PreparedStatement ps = [Link](
"INSERT INTO messages(sender_email, receiver_email, message) VALUES(?,?,?)")) {
[Link](1, sender);
[Link](2, receiver);
[Link](3, [Link]());
[Link]();
} catch (Exception e) { [Link](); }
[Link]("[Link]?with=" + receiver);
}
}
[Link]
package [Link];
import [Link];
i t j t til OTPG t
import [Link];
import [Link].*;
import [Link].*;
import [Link];
public class SendOTPServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String name = [Link]("name");
String email = [Link]("email");
String password = [Link]("password");
String address = [Link]("address");
// Generate OTP
String otp = [Link]();
long otpGeneratedTime = [Link](); // milliseconds
long otpValidDuration = 2 * 60 * 1000; // 2 mins in ms
// Save data + OTP info in session
HttpSession session = [Link]();
[Link]("name", name);
[Link]("email", email);
[Link]("password", password);
[Link]("address", address);
[Link]("otp", otp);
[Link]("otpTime", otpGeneratedTime);
[Link]("otpValidDuration", otpValidDuration);
[Link]("otpAttempts", 0);
// Send OTP via email
boolean emailSent = [Link](email, "Your OTP Code", "Your OTP is: " + otp);
if (emailSent) {
[Link]("[Link]");
} else {
[Link]().println("Failed to send OTP. Please try again.");
}
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
i tj k t l t htt *
p j p g;
import [Link].*;
import [Link].*;
import [Link].*;
@MultipartConfig(maxFileSize = 1024*1024*5) // 5MB
public class UpdagePhotoServletAdmin extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
HttpSession session = [Link]();
String email = (String) [Link]("userEmail");
if(email == null) {
[Link]("[Link]");
return;
}
Part filePart = [Link]("photo");
if(filePart != null && [Link]() > 0) {
try(InputStream is = [Link]();
Connection conn = [Link]()) {
String sql = "UPDATE user SET photo=? WHERE email_phone=?";
PreparedStatement ps = [Link](sql);
[Link](1, is);
[Link](2, email);
[Link]();
} catch (Exception e) {
[Link]();
}
}
[Link]("[Link]");
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link].*;
@MultipartConfig(maxFileSize = 1024 * 1024 * 5) // 5MB
public class UpdateAccountServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
HttpSession session = [Link]();
String email = (String) [Link]("userEmail");
if(email == null){
[Link]("[Link]");
return;
}
String name = [Link]("name");
String address = [Link]("address");
Part photoPart = [Link]("photo");
try(Connection conn = [Link]()){
String sql;
PreparedStatement ps;
if(photoPart != null && [Link]() > 0){
InputStream photoStream = [Link]();
sql = "UPDATE user SET name=?, address=?, photo=? WHERE email_phone=?";
ps = [Link](sql);
[Link](1, name);
[Link](2, address);
[Link](3, photoStream);
[Link](4, email);
} else {
sql = "UPDATE user SET name=?, address=? WHERE email_phone=?";
ps = [Link](sql);
[Link](1, name);
[Link](2, address);
[Link](3, email);
}
int updated = [Link]();
if(updated > 0){
// update session name
[Link]("userName", name);
[Link]("[Link]?msg=success");
} else {
[Link]("[Link]?msg=fail");
}
} catch(Exception e){
[Link]();
[Link]("[Link]?msg=error");
}
}
}
U l dPh t S l tj
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link].*;
import [Link].*;
@MultipartConfig(maxFileSize = 1024*1024*5) // 5MB
public class UploadPhotoServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
HttpSession session = [Link]();
String email = (String) [Link]("userEmail");
if(email == null) {
[Link]("[Link]");
return;
}
Part filePart = [Link]("photo");
if(filePart != null && [Link]() > 0) {
try(InputStream is = [Link]();
Connection conn = [Link]()) {
String sql = "UPDATE user SET photo=? WHERE email_phone=?";
PreparedStatement ps = [Link](sql);
[Link](1, is);
[Link](2, email);
[Link]();
} catch (Exception e) {
[Link]();
}
}
[Link]("[Link]");
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link].*;
import [Link].*;
import [Link];
import [Link];
i tj lC ti
p j ;
import [Link];
import [Link];
public class VerifyOTPServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = [Link]();
String enteredOtp = [Link]("otp");
String sessionOtp = (String) [Link]("otp");
Long otpTime = (Long) [Link]("otpTime");
Long otpValidDuration = (Long) [Link]("otpValidDuration");
Integer attempts = (Integer) [Link]("otpAttempts");
if (attempts == null) attempts = 0;
[Link]("text/html;charset=UTF-8");
PrintWriter out = [Link]();
// Max attempts check
if (attempts >= 3) {
❌
[Link]("<script>alert(' Maximum OTP attempts reached. Please request a new
OTP.');[Link]='[Link]';</script>");
return;
}
// Increment attempt counter
attempts++;
[Link]("otpAttempts", attempts);
// OTP expiration check
if (otpTime == null || ([Link]() - otpTime > otpValidDuration)) {
[Link]("<script>alert('
</script>");
❌ OTP expired. Please request a new OTP.');[Link]='[Link]';
return;
}
// Verify OTP
if (sessionOtp != null && [Link](enteredOtp)) {
try (Connection conn = [Link]()) {
String sql = "INSERT INTO user (name,email_phone,psd,address,createtime,role)
VALUES(?,?,?,?,NOW(),'USER')"; // note: role='USER'
PreparedStatement stmt = [Link](sql);
[Link](1, (String) [Link]("name"));
[Link](2, (String) [Link]("email"));
[Link](3, [Link]((String) [Link]("password")));
[Link](4, (String) [Link]("address"));
[Link]();
// Clear session OTP data
[Link]("otp");
[Link]("otpTime");
i Att ib t (" t V lidD ti ")
[Link]("otpValidDuration");
[Link]("otpAttempts");
[Link]("name");
[Link]("email");
[Link]("password");
[Link]("address");
[Link]("<script>alert('
</script>");
✅ Account Created Successfully!');[Link]='[Link]';
} catch (Exception e) {
[Link]();
[Link]("<script>alert('Error creating account: " + [Link]() + "');[Link]();
</script>");
}
} else {
[Link]("<script>alert('
</script>");
❌ Invalid OTP. Attempts left: " + (3 - attempts) + "');[Link]();
}
}
}
project > brand > [Link]
package [Link];
public class Brand {
private int id;
private String name;
private byte[] logo;
private String base64Image;
// Constructors
public Brand() {}
public Brand(String name, byte[] logo) {
[Link] = name;
[Link] = logo;
}
public Brand(int id, String name, byte[] logo) {
[Link] = id;
[Link] = name;
[Link] = logo;
}
// Getters and Setters
public int getId() { return id; }
public void setId(int id) { [Link] = id; }
public String getName() { return name; }
public void setName(String name) { [Link] = name; }
bli b t [] g tL g () { t l g }
public byte[] getLogo() { return logo; }
public void setLogo(byte[] logo) { [Link] = logo; }
public String getImage() { return base64Image; }
public void setImage(String base64Image) {
this.base64Image = base64Image;
}
}
[Link]
package [Link];
import [Link].*;
import [Link].*;
import [Link].Base64;
import [Link];
public class BrandDAO {
private final Connection connection;
public BrandDAO() throws SQLException {
[Link] = [Link]();
}
public List<Brand> getAllBrands() throws SQLException {
List<Brand> brands = new ArrayList<>();
String query = "SELECT id, name, logo FROM brand";
try (PreparedStatement ps = [Link](query);
ResultSet rs = [Link]()) {
while ([Link]()) {
Brand brand = new Brand();
[Link]([Link]("id"));
[Link]([Link]("name"));
Blob logoBlob = [Link]("logo");
if (logoBlob != null) {
byte[] logoBytes = [Link](1, (int) [Link]());
[Link](logoBytes);
[Link]([Link]().encodeToString(logoBytes));
}
[Link](brand);
}
}
return brands;
}
// Add this method to get a single brand by ID
public Brand getBrandById(int id) throws SQLException {
String query = "SELECT id, name, logo FROM brand WHERE id = ?";
B db d ll
Brand brand = null;
try (PreparedStatement ps = [Link](query)) {
[Link](1, id);
try (ResultSet rs = [Link]()) {
if ([Link]()) {
brand = new Brand();
[Link]([Link]("id"));
[Link]([Link]("name"));
Blob logoBlob = [Link]("logo");
if (logoBlob != null) {
byte[] logoBytes = [Link](1, (int) [Link]());
[Link](logoBytes);
[Link]([Link]().encodeToString(logoBytes));
}
}
}
}
return brand;
}
public void addBrand(Brand brand) throws SQLException {
String query = "INSERT INTO brand (name, logo) VALUES (?, ?)";
try (PreparedStatement ps = [Link](query)) {
[Link](1, [Link]());
[Link](2, [Link]());
[Link]();
}
}
// Add update method
public boolean updateBrand(Brand brand) throws SQLException {
String query;
if ([Link]() != null && [Link]().length > 0) {
query = "UPDATE brand SET name = ?, logo = ? WHERE id = ?";
} else {
query = "UPDATE brand SET name = ? WHERE id = ?";
}
try (PreparedStatement ps = [Link](query)) {
[Link](1, [Link]());
if ([Link]() != null && [Link]().length > 0) {
[Link](2, [Link]());
[Link](3, [Link]());
} l {
p ( , g ());
} else {
[Link](2, [Link]());
}
return [Link]() > 0;
}
}
// Add delete method
public boolean deleteBrand(int id) throws SQLException {
String query = "DELETE FROM brand WHERE id = ?";
try (PreparedStatement ps = [Link](query)) {
[Link](1, id);
int rowsAffected = [Link]();
return rowsAffected > 0;
}
}
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
@MultipartConfig(maxFileSize = 1024 * 1024 * 5) // 5MB limit
public class BrandServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private BrandDAO brandDAO;
@Override
public void init() throws ServletException {
try {
brandDAO = new BrandDAO();
} catch (SQLException e) {
throw new ServletException("DB init error: " + [Link](), e);
} catch (Exception e) {
throw new ServletException("Unexpected error: " + [Link](), e);
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
th S l tE ti IOE ti {
throws ServletException, IOException {
try {
String action = [Link]("action");
if ("edit".equals(action)) {
// Handle edit form request
handleEditForm(request, response);
} else {
// Default: show all brands
[Link]("brandList", [Link]());
[Link]("/[Link]").forward(request, response);
}
} catch (SQLException e) {
[Link]("error", "Database error: " + [Link]());
try {
[Link]("brandList", [Link]());
} catch (SQLException ex) {
[Link]("error", "Database error: " + [Link]());
}
[Link]("/[Link]").forward(request, response);
}
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String action = [Link]("action");
if ("delete".equals(action)) {
handleDelete(request, response);
} else if ("update".equals(action)) {
handleUpdate(request, response);
} else {
handleAdd(request, response);
}
}
private void handleEditForm(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String idParam = [Link]("id");
if (idParam == null || [Link]()) {
[Link]("error", "Invalid brand ID");
try {
t tAtt ib t ("b dLi t" b dDAO g tAllB d ())
y{
[Link]("brandList", [Link]());
} catch (SQLException e) {
[Link]("error", "Database error: " + [Link]());
}
[Link]("/[Link]").forward(request, response);
return;
}
try {
int id = [Link](idParam);
Brand brand = [Link](id);
if (brand != null) {
[Link]("editBrand", brand);
[Link]("brandList", [Link]());
[Link]("/[Link]").forward(request, response);
} else {
[Link]("error", "Brand not found");
[Link]("brandList", [Link]());
[Link]("/[Link]").forward(request, response);
}
} catch (NumberFormatException e) {
[Link]("error", "Invalid brand ID format");
try {
[Link]("brandList", [Link]());
} catch (SQLException ex) {
[Link]("error", "Database error: " + [Link]());
}
[Link]("/[Link]").forward(request, response);
} catch (SQLException e) {
[Link]("error", "Database error: " + [Link]());
try {
[Link]("brandList", [Link]());
} catch (SQLException ex) {
[Link]("error", "Database error: " + [Link]());
}
[Link]("/[Link]").forward(request, response);
}
}
private void handleAdd(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String name = [Link]("name");
Part logoPart = [Link]("logo");
if (!isValidImage(logoPart)) {
[Link]("error", "Invalid image format. Only JPG/PNG allowed");
try {
[Link]("brandList", [Link]());
} catch (SQLException e) {
[Link]("error", "Database error: " + [Link]());
}
[Link]("/[Link]").forward(request, response);
return;
}
try {
Brand brand = new Brand(name, [Link]().readAllBytes());
[Link](brand);
[Link]("success", "Brand added successfully");
[Link]("brandList", [Link]());
[Link]("/[Link]").forward(request, response);
} catch (SQLException | IOException e) {
[Link]("error", "Add failed: " + [Link]());
try {
[Link]("brandList", [Link]());
} catch (SQLException ex) {
[Link]("error", "Database error: " + [Link]());
}
[Link]("/[Link]").forward(request, response);
}
}
private void handleUpdate(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String idParam = [Link]("id");
String name = [Link]("name");
Part logoPart = [Link]("logo");
if (idParam == null || [Link]()) {
[Link]("error", "Invalid brand ID");
try {
[Link]("brandList", [Link]());
} catch (SQLException e) {
[Link]("error", "Database error: " + [Link]());
}
[Link]("/[Link]").forward(request, response);
return;
}
}
try {
int id = [Link](idParam);
Brand brand = new Brand();
[Link](id);
[Link](name);
// Only update logo if a new one was provided
if (logoPart != null && [Link]() > 0) {
if (!isValidImage(logoPart)) {
[Link]("error", "Invalid image format. Only JPG/PNG allowed");
[Link]("brandList", [Link]());
[Link]("/[Link]").forward(request, response);
return;
}
[Link]([Link]().readAllBytes());
} else {
// Keep existing logo
Brand existingBrand = [Link](id);
if (existingBrand != null) {
[Link]([Link]());
}
}
boolean updated = [Link](brand);
if (updated) {
[Link]("success", "Brand updated successfully");
} else {
[Link]("error", "Failed to update brand");
}
[Link]("brandList", [Link]());
[Link]("/[Link]").forward(request, response);
} catch (NumberFormatException e) {
[Link]("error", "Invalid brand ID format");
try {
[Link]("brandList", [Link]());
} catch (SQLException ex) {
[Link]("error", "Database error: " + [Link]());
}
[Link]("/[Link]").forward(request, response);
} catch (SQLException e) {
[Link]("error", "Database error: " + [Link]());
try {
[Link]("brandList", [Link]());
} t h (SQLE ti ){
} catch (SQLException ex) {
[Link]("error", "Database error: " + [Link]());
}
[Link]("/[Link]").forward(request, response);
}
}
private void handleDelete(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String idParam = [Link]("id");
if (idParam == null || [Link]()) {
[Link]("error", "Invalid brand ID");
try {
[Link]("brandList", [Link]());
} catch (SQLException e) {
[Link]("error", "Database error: " + [Link]());
}
[Link]("/[Link]").forward(request, response);
return;
}
try {
int id = [Link](idParam);
boolean deleted = [Link](id);
if (deleted) {
[Link]("success", "Brand deleted successfully");
} else {
[Link]("error", "Failed to delete brand");
}
[Link]("brandList", [Link]());
} catch (NumberFormatException e) {
[Link]("error", "Invalid brand ID format");
} catch (SQLException e) {
[Link]("error", "Database error: " + [Link]());
}
[Link]("/[Link]").forward(request, response);
}
private boolean isValidImage(Part part) {
if (part == null || [Link]() == 0) return false;
String contentType = [Link]();
return contentType != null &&
( t tT l ("i g /j g") || t tT l ("i g / g"))
yp
([Link]("image/jpeg") || [Link]("image/png"));
}
}
Category> [Link]
package [Link];
public class Category {
private int cgid;
private String cgname;
public Category() {}
public Category(String cgname) {
[Link] = cgname;
}
public Category(int cgid, String cgname) {
[Link] = cgid;
[Link] = cgname;
}
public int getCgid() {
return cgid;
}
public void setCgid(int cgid) {
[Link] = cgid;
}
public String getCgname() {
return cgname;
}
public void setCgname(String cgname) {
[Link] = cgname;
}
}
[Link]
package [Link];
import [Link].*;
import [Link].*;
import [Link];
import [Link];
public class CategoryDAO {
private Connection con;
public CategoryDAO() {
con = [Link]();
}
public boolean insertCategory(Category category) {
String sql = "INSERT INTO category (name) VALUES (?)";
try (PreparedStatement ps = [Link](sql)) {
[Link](1, [Link]());
return [Link]() > 0;
} catch (Exception e) {
[Link]();
}
return false;
}
public List<Category> getAllCategories() {
List<Category> list = new ArrayList<>();
String sql = "SELECT * FROM category ORDER BY id ASC";
try (Statement stmt = [Link]();
ResultSet rs = [Link](sql)) {
while ([Link]()) {
[Link](new Category([Link]("id"), [Link]("name")));
}
} catch (Exception e) {
[Link]();
}
return list;
}
}
[Link]
package [Link];
import [Link].*;
import [Link];
import [Link].*;
import [Link];
public class CategoryServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
St i g g t g tP t (" g ")
String cgname = [Link]("cgname");
Category category = new Category(cgname);
CategoryDAO dao = new CategoryDAO();
String msg;
if ([Link](category)) {
msg = "Category added successfully.";
} else {
msg = "Failed to add category. It may already exist.";
}
[Link]("msg", msg);
RequestDispatcher rd = [Link]("[Link]");
[Link](request, response);
}
}
product> [Link]
package [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
public class CartDAO {
public int getQuantity(int uid, int pid) {
String sql = "SELECT quantity FROM cartitem WHERE uid=? AND pid=?";
try (Connection c = [Link]();
PreparedStatement ps = [Link](sql)) {
[Link](1, uid);
[Link](2, pid);
ResultSet rs = [Link]();
return [Link]() ? [Link](1) : 0;
} catch (Exception e) {
[Link]();
return 0;
}
}
public void updateQuantity(int uid, int pid, int qty) {
String sql =
"INSERT INTO cartitem(uid,pid,quantity,addtime) VALUES(?,?,?,NOW()) " +
"ON DUPLICATE KEY UPDATE quantity=VALUES(quantity), addtime=NOW()";
try (Connection c = [Link]();
PreparedStatement ps = [Link](sql)) {
tI t(1 id)
[Link](1, uid);
[Link](2, pid);
[Link](3, qty);
[Link]();
} catch (Exception e) {
[Link]();
}
}
public List<CartItem> getAllFor(int uid) {
String sql = "SELECT [Link], [Link], [Link], [Link], [Link], [Link] " +
"FROM cartitem c JOIN product p ON [Link] = [Link] " +
"WHERE [Link] = ? ORDER BY [Link]";
List<CartItem> list = new ArrayList<>();
try (Connection c = [Link]();
PreparedStatement ps = [Link](sql)) {
[Link](1, uid);
ResultSet rs = [Link]();
while ([Link]()) {
[Link](new CartItem(
[Link]("pid"),
[Link]("name"),
[Link]("quantity"),
[Link]("price"),
[Link]("saleprice"),
[Link]("image")
));
}
} catch (Exception e) { [Link](); }
return list;
}
public void clear(int uid) {
try (Connection c = [Link]();
PreparedStatement ps = [Link]("DELETE FROM cartitem WHERE uid=?")) {
[Link](1, uid);
[Link]();
} catch (Exception e) { [Link](); }
}
public int getPrice(int pid) {
String sql = "SELECT CASE WHEN saleprice > 0 THEN saleprice ELSE price END AS currentPrice " +
"FROM product WHERE id = ?";
try (Connection c = [Link]();
PreparedStatement ps = [Link](sql)) {
[Link](1, pid);
ResultSet rs = [Link]();
t t() ? g tI t(" tP i ") 0
p Q y();
return [Link]() ? [Link]("currentPrice") : 0;
} catch (Exception e) {
[Link]();
return 0;
}
}
}
[Link]
package [Link];
public class CartItem {
private final int pid, qty, price, salePrice;
private final String name;
private final byte[] image;
public CartItem(int pid, String name, int qty, int price, int salePrice, byte[] img) {
[Link] = pid; [Link] = name; [Link] = qty;
[Link] = price; [Link] = salePrice; [Link] = img;
}
public int getPid() { return pid; }
public int getQty() { return qty; }
public int getEffectivePrice() { return salePrice > 0 ? salePrice : price; }
public String getName() { return name; }
public String getBase64Image() {
return [Link]().encodeToString(image);
}
}
[Link]
package [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
public class OrderDAO {
public int createOrder(int uid, String address, String phone, int total) throws SQLException {
String sql = "INSERT INTO cus_order(uid, odate, totalamount, deliaddress, phone) " +
"VALUES(?, NOW(), ?, ?, ?)";
try (Connection c = [Link]();
PreparedStatement ps = [Link](sql, Statement.RETURN_GENERATED_KEYS)) {
[Link](1, uid);
[Link](2, total);
[Link](3, address);
tSt i g(4 h )
[Link](4, phone);
[Link]();
ResultSet rs = [Link]();
return [Link]() ? [Link](1) : -1;
}
}
public void addOrderItem(int oid, int pid, int qty, int price) throws SQLException {
String sql = "INSERT INTO order_item(oid, pid, quantity, price) VALUES(?,?,?,?)";
try (Connection c = [Link]();
PreparedStatement ps = [Link](sql)) {
[Link](1, oid);
[Link](2, pid);
[Link](3, qty);
[Link](4, price);
[Link]();
}
}
public OrderDetail getOrderDetail(int oid, int uid) throws SQLException {
String sql = "SELECT [Link], [Link], [Link], [Link], [Link] " +
"FROM cus_order o WHERE [Link]=? AND [Link]=?";
try (Connection c = [Link]();
PreparedStatement ps = [Link](sql)) {
[Link](1, oid); [Link](2, uid);
ResultSet rs = [Link]();
if (![Link]()) return null;
OrderDetail od = new OrderDetail();
[Link]([Link]("id"));
[Link]([Link]("odate").toString());
[Link]([Link]("totalamount"));
[Link]([Link]("deliaddress"));
[Link]([Link]("phone"));
String itemSql = "SELECT [Link], [Link], [Link] " +
"FROM order_item i JOIN product p ON [Link] = [Link] " +
"WHERE [Link] = ?";
List<OrderItem> list = new ArrayList<>();
try (PreparedStatement ps2 = [Link](itemSql)) {
[Link](1, oid);
ResultSet rs2 = [Link]();
while ([Link]()) {
[Link](new OrderItem(
[Link]("quantity"),
[Link]("price"),
2 g tSt i g(" ")
g ( p ),
[Link]("name")
));
}
}
[Link](list);
return od;
}
}
// Admin: all orders | Customer: only mine
public List<OrderDetail> getAllOrders(Integer uid) throws SQLException {
String sql = uid == null
? "SELECT [Link], [Link], [Link], [Link], [Link], [Link] as userName " +
"FROM cus_order o JOIN user u ON [Link] = [Link] ORDER BY [Link] DESC"
: "SELECT [Link], [Link], [Link], [Link], [Link], [Link] as userName " +
"FROM cus_order o JOIN user u ON [Link] = [Link] WHERE [Link]=? ORDER BY [Link] DESC";
List<OrderDetail> orders = new ArrayList<>();
try (Connection c = [Link]();
PreparedStatement ps = [Link](sql)) {
if (uid != null) [Link](1, uid);
ResultSet rs = [Link]();
while ([Link]()) {
OrderDetail od = new OrderDetail();
[Link]([Link]("id"));
[Link]([Link]("odate").toString());
[Link]([Link]("totalamount"));
[Link]([Link]("deliaddress"));
[Link]([Link]("phone"));
[Link]([Link]("userName")); // new field in bean
// items
String itemSql = "SELECT [Link], [Link], [Link] " +
"FROM order_item i JOIN product p ON [Link] = [Link] " +
"WHERE [Link] = ?";
List<OrderItem> items = new ArrayList<>();
try (PreparedStatement ps2 = [Link](itemSql)) {
[Link](1, [Link]());
ResultSet rs2 = [Link]();
while ([Link]()) {
[Link](new OrderItem([Link]("quantity"),
[Link]("price"),
[Link]("name")));
}
}
d tIt (it )
}
[Link](items);
[Link](od);
}
}
return orders;
}
}
[Link]
package [Link];
import [Link];
public class OrderDetail {
private int orderId;
private int total;
private String orderDate;
private String address;
private String phone;
private String userName;
private List<OrderItem> items;
// Constructors
public OrderDetail() { }
public OrderDetail(int orderId, int total, String orderDate,
String address, String phone, List<OrderItem> items, String userName) {
[Link] = orderId;
[Link] = total;
[Link] = orderDate;
[Link] = address;
[Link] = phone;
[Link] = userName;
[Link] = items;
}
// Getters & Setters
public int getOrderId() { return orderId; }
public void setOrderId(int orderId) { [Link] = orderId; }
public int getTotal() { return total; }
public void setTotal(int total) { [Link] = total; }
public String getOrderDate() { return orderDate; }
public void setOrderDate(String orderDate) { [Link] = orderDate; }
public String getAddress() { return address; }
public void setAddress(String address) { [Link] = address; }
public String getPhone() { return phone; }
public void setPhone(String phone) { [Link] = phone; }
public String getuserName() { return userName; }
public void setuserName(String userName) { [Link] = userName; }
public List<OrderItem> getItems() { return items; }
public void setItems(List<OrderItem> items) { [Link] = items; }
}
[Link]
package [Link];
public class OrderItem {
private int qty;
private int price;
private String name;
// Constructors
public OrderItem() { }
public OrderItem(int qty, int price, String name) {
[Link] = qty;
[Link] = price;
[Link] = name;
}
// Getters & Setters
public int getQty() { return qty; }
public void setQty(int qty) { [Link] = qty; }
public int getPrice() { return price; }
public void setPrice(int price) { [Link] = price; }
public String getName() { return name; }
public void setName(String name) { [Link] = name; }
}
[Link]
package [Link];
import [Link];
import [Link];
import [Link].Base64;
public class Product {
private int id;
private String name;
private String description;
i t i t bid
private int bid;
private int cgid;
private String skinType;
private int price;
private Date expireDate;
private int salePrice;
private int stock;
private byte[] image;
private Timestamp createTime;
private String brandName;
private String categoryName;
private String ageRange;
// Getters and Setters
public int getId() {
return id;
}
public void setId(int id) {
[Link] = id;
}
public String getName() {
return name;
}
public void setName(String name) {
[Link] = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
[Link] = description;
}
public int getBid() {
return bid;
}
public void setBid(int bid) {
[Link] = bid;
}
public int getCgid() {
return cgid;
}
public void setCgid(int cgid) {
thi gid gid
p g ( g ){
[Link] = cgid;
}
public String getSkinType() {
return skinType;
}
public void setSkinType(String skinType) {
[Link] = skinType;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
[Link] = price;
}
public Date getExpireDate() {
return expireDate;
}
public void setExpireDate(Date expireDate) {
[Link] = expireDate;
}
public int getSalePrice() {
return salePrice;
}
public void setSalePrice(int salePrice) {
[Link] = salePrice;
}
public int getStock() {
return stock;
}
public void setStock(int stock) {
[Link] = stock;
}
public byte[] getImage() {
return image;
}
public void setImage(byte[] image) {
[Link] = image;
}
public Timestamp getCreateTime() {
return createTime;
}
;
}
public void setCreateTime(Timestamp createTime) {
[Link] = createTime;
}
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
[Link] = brandName;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
[Link] = categoryName;
}
public String getAgeRange() {
return ageRange;
}
public void setAgeRange(String ageRange) {
[Link] = ageRange;
}
// Utility methods
public boolean isOnSale() {
return salePrice > 0 && salePrice < price;
}
public boolean isExpired() {
return expireDate != null && [Link](new [Link]());
}
public boolean isLowStock() {
return stock < 10;
}
public String getFormattedPrice() {
return [Link]("%,d MMK", price);
}
public String getFormattedSalePrice() {
return [Link]("%,d MMK", salePrice);
}
public String getImageBase64() {
if (image != null && [Link] > 0) {
t "d t i g /j g b 64 " B 64 g tE d () d T St i g(i g )
( g g g ){
return "data:image/jpeg;base64," + [Link]().encodeToString(image);
}
return "";
}
public boolean hasImage() {
return image != null && [Link] > 0;
}
}
[Link]
package [Link];
import [Link];
import [Link].*;
import [Link].*;
public class ProductDAO {
public Map<String, List<Product>> getProductsGroupedByCategory() throws SQLException {
Map<String, List<Product>> productsByCategory = new LinkedHashMap<>();
String query = "SELECT p.*, [Link] AS brand_name, [Link] AS category_name " +
"FROM product p " +
"LEFT JOIN brand b ON [Link] = [Link] " +
"LEFT JOIN category c ON [Link] = [Link] " +
"ORDER BY [Link], [Link]";
try (Connection conn = [Link]();
PreparedStatement stmt = [Link](query);
ResultSet rs = [Link]()) {
while ([Link]()) {
Product product = new Product();
[Link]([Link]("id"));
[Link]([Link]("name"));
[Link]([Link]("description"));
[Link]([Link]("bid"));
[Link]([Link]("cgid"));
[Link]([Link]("skintype"));
[Link]([Link]("price"));
[Link]([Link]("expiredate"));
[Link]([Link]("saleprice"));
[Link]([Link]("stock"));
[Link]([Link]("image"));
[Link]([Link]("createtime"));
[Link]([Link]("brand_name"));
[Link]([Link]("category_name"));
[Link]([Link]("age_range"));
String categoryName = [Link]() != null ?
[Link]() : "Uncategorized";
[Link](categoryName, k -> new ArrayList<>()).add(product);
}
}
return productsByCategory;
}
public int addProduct(Product product) throws SQLException {
String sql = "INSERT INTO product (name, description, bid, cgid, skintype, price, expiredate, " +
"saleprice, stock, image, createtime, age_range) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try (Connection conn = [Link]();
PreparedStatement stmt = [Link](sql, Statement.RETURN_GENERATED_KEYS)) {
[Link](1, [Link]());
[Link](2, [Link]());
[Link](3, [Link]());
[Link](4, [Link]());
[Link](5, [Link]());
[Link](6, [Link]());
[Link](7, [Link]() != null ?
new [Link]([Link]().getTime()) : null);
[Link](8, [Link]());
[Link](9, [Link]());
[Link](10, [Link]());
[Link](11, new Timestamp([Link]()));
[Link](12, [Link]());
int affectedRows = [Link]();
if (affectedRows > 0) {
try (ResultSet rs = [Link]()) {
if ([Link]()) {
return [Link](1);
}
}
}
return -1;
}
}
public boolean updateProduct(Product product) throws SQLException {
String sql = "UPDATE product SET name=?, description=?, bid=?, cgid=?, skintype=?, price=?, " +
"expiredate=?, saleprice=?, stock=?, image=?, age_range=? WHERE id=?";
try (Connection conn = [Link]();
P dSt t t t t St t t( l)) {
y( g ();
PreparedStatement stmt = [Link](sql)) {
[Link](1, [Link]());
[Link](2, [Link]());
[Link](3, [Link]());
[Link](4, [Link]());
[Link](5, [Link]());
[Link](6, [Link]());
[Link](7, [Link]() != null ?
new [Link]([Link]().getTime()) : null);
[Link](8, [Link]());
[Link](9, [Link]());
[Link](10, [Link]());
[Link](11, [Link]());
[Link](12, [Link]());
return [Link]() > 0;
}
}
public boolean deleteProduct(int id) throws SQLException {
String sql = "DELETE FROM product WHERE id=?";
try (Connection conn = [Link]();
PreparedStatement stmt = [Link](sql)) {
[Link](1, id);
return [Link]() > 0;
}
}
public Product getProductById(int id) throws SQLException {
String sql = "SELECT * FROM product WHERE id=?";
try (Connection conn = [Link]();
PreparedStatement stmt = [Link](sql)) {
[Link](1, id);
try (ResultSet rs = [Link]()) {
if ([Link]()) {
Product product = new Product();
[Link]([Link]("id"));
[Link]([Link]("name"));
[Link]([Link]("description"));
[Link]([Link]("bid"));
[Link]([Link]("cgid"));
[Link]([Link]("skintype"));
[Link]([Link]("price"));
[Link]([Link]("expiredate"));
[Link]([Link]("saleprice"));
[Link]([Link]("stock"));
d t tI g ( g tB t ("i g "))
p ( g ( ));
[Link]([Link]("image"));
[Link]([Link]("createtime"));
[Link]([Link]("age_range"));
return product;
}
}
}
return null;
}
// Get non-expired products for home page
public Map<String, List<Product>> getNonExpiredProductsGroupedByCategory() throws SQLException {
Map<String, List<Product>> productsByCategory = new LinkedHashMap<>();
String query = "SELECT p.*, [Link] AS brand_name, [Link] AS category_name " +
"FROM product p " +
"LEFT JOIN brand b ON [Link] = [Link] " +
"LEFT JOIN category c ON [Link] = [Link] " +
"WHERE ([Link] IS NULL OR [Link] >= CURDATE()) " +
"ORDER BY [Link], [Link]";
try (Connection conn =[Link]();
PreparedStatement stmt = [Link](query);
ResultSet rs = [Link]()) {
while ([Link]()) {
Product product = new Product();
[Link]([Link]("id"));
[Link]([Link]("name"));
[Link]([Link]("description"));
[Link]([Link]("bid"));
[Link]([Link]("cgid"));
[Link]([Link]("skintype"));
[Link]([Link]("price"));
[Link]([Link]("expiredate"));
[Link]([Link]("saleprice"));
[Link]([Link]("stock"));
[Link]([Link]("image"));
[Link]([Link]("createtime"));
[Link]([Link]("brand_name"));
[Link]([Link]("category_name"));
[Link]([Link]("age_range"));
String categoryName = [Link]() != null ?
[Link]() : "Uncategorized";
[Link](categoryName, k -> new ArrayList<>()).add(product);
}
}
}
return productsByCategory;
}
// Utility methods for dropdowns
public List<Map<String, Object>> getAllBrands() throws SQLException {
List<Map<String, Object>> brands = new ArrayList<>();
String sql = "SELECT id, name FROM brand";
try (Connection conn = [Link]();
PreparedStatement stmt = [Link](sql);
ResultSet rs = [Link]()) {
while ([Link]()) {
Map<String, Object> brand = new HashMap<>();
[Link]("id", [Link]("id"));
[Link]("name", [Link]("name"));
[Link](brand);
}
}
return brands;
}
public List<Map<String, Object>> getAllCategories() throws SQLException {
List<Map<String, Object>> categories = new ArrayList<>();
String sql = "SELECT id, name FROM category";
try (Connection conn = [Link]();
PreparedStatement stmt = [Link](sql);
ResultSet rs = [Link]()) {
while ([Link]()) {
Map<String, Object> category = new HashMap<>();
[Link]("id", [Link]("id"));
[Link]("name", [Link]("name"));
[Link](category);
}
}
return categories;
}
public List<String> getAllSkinTypes() throws SQLException {
List<String> skinTypes = new ArrayList<>();
String sql = "SELECT DISTINCT skintype FROM product WHERE skintype IS NOT NULL AND skintype !=
''";
try (Connection conn = [Link]();
PreparedStatement stmt = [Link](sql);
ResultSet rs = [Link]()) {
hil ( t()) {
Q y()) {
while ([Link]()) {
[Link]([Link]("skintype"));
}
}
return skinTypes;
}
}
[Link]
package [Link];
import [Link].*;
import [Link].*;
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@MultipartConfig(
fileSizeThreshold = 1024 * 1024, // 1MB
maxFileSize = 1024 * 1024 * 10, // 10MB
maxRequestSize = 1024 * 1024 * 50 // 50MB
)
public class ProductServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private ProductDAO productDAO = new ProductDAO();
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String action = [Link]("action");
try {
if ("edit".equals(action)) {
showEditForm(request, response);
} else if ("delete".equals(action)) {
deleteProduct(request, response);
} else {
listProducts(request, response);
}
} t h (SQLE ti ){
}
} catch (SQLException e) {
throw new ServletException("Database error", e);
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String action = [Link]("action");
try {
if ("update".equals(action)) {
updateProduct(request, response);
} else {
addProduct(request, response);
}
} catch (SQLException | ParseException ex) {
throw new ServletException(ex);
}
}
private void listProducts(HttpServletRequest request, HttpServletResponse response)
throws SQLException, ServletException, IOException {
Map<String, List<Product>> productsByCategory = [Link]();
List<String> skinTypes = [Link]();
[Link]("productsByCategory", productsByCategory);
[Link]("skinTypes", skinTypes);
[Link]("/[Link]").forward(request, response);
}
private void showEditForm(HttpServletRequest request, HttpServletResponse response)
throws SQLException, ServletException, IOException {
int id = [Link]([Link]("id"));
Product product = [Link](id);
if (product == null) {
[Link]("message", " ❌ Product not found");
listProducts(request, response);
return;
}
[Link]("product", product);
[Link]("isEdit", true);
li tP d t ( t )
listProducts(request, response);
}
private void addProduct(HttpServletRequest request, HttpServletResponse response)
throws SQLException, IOException, ServletException, ParseException {
Product product = new Product();
populateProductFromRequest(request, product);
int productId = [Link](product);
if (productId > 0) {
[Link]("message", " ✅ Product added successfully! ID: " + productId);
[Link]("isSuccess", true);
} else {
[Link]("message", " ❌ Failed to add product");
[Link]("hasError", true);
}
listProducts(request, response);
}
private void updateProduct(HttpServletRequest request, HttpServletResponse response)
throws SQLException, IOException, ServletException, ParseException {
int id = [Link]([Link]("id"));
Product product = [Link](id);
if (product == null) {
[Link]("message", " ❌ Product not found");
listProducts(request, response);
return;
}
populateProductFromRequest(request, product);
[Link](id);
if ([Link](product)) {
[Link]("message", " ✅ Product updated successfully!");
[Link]("isSuccess", true);
} else {
[Link]("message", " ❌ Failed to update product");
[Link]("hasError", true);
}
listProducts(request, response);
}
}
private void deleteProduct(HttpServletRequest request, HttpServletResponse response)
throws SQLException, IOException, ServletException {
int id = [Link]([Link]("id"));
if ([Link](id)) {
[Link]("message", " ✅ Product deleted successfully!");
[Link]("isSuccess", true);
} else {
[Link]("message", " ❌ Failed to delete product");
[Link]("hasError", true);
}
listProducts(request, response);
}
private void populateProductFromRequest(HttpServletRequest request, Product product)
throws ParseException, IOException, ServletException, NumberFormatException, SQLException {
// Set name
[Link]([Link]("name"));
// Set description
[Link]([Link]("description"));
// Set bid with null check
String bidStr = [Link]("bid");
if (bidStr != null && ![Link]().isEmpty()) {
try {
[Link]([Link](bidStr));
} catch (NumberFormatException e) {
[Link](1); // Set default brand
}
} else {
[Link](1); // Set default brand
}
// Set cgid with null check
String cgidStr = [Link]("cgid");
if (cgidStr != null && ![Link]().isEmpty()) {
try {
[Link]([Link](cgidStr));
} catch (NumberFormatException e) {
d t tCgid(1) // S t d f lt t g
[Link](1); // Set default category
}
} else {
[Link](1); // Set default category
}
// Set skinType (can be null)
[Link]([Link]("skinType"));
// Set price with null check
String priceStr = [Link]("price");
if (priceStr != null && ![Link]().isEmpty()) {
try {
[Link]([Link](priceStr));
} catch (NumberFormatException e) {
[Link](0); // Set default price
}
} else {
[Link](0); // Set default price
}
// Set expireDate (can be null)
String expireDateStr = [Link]("expireDate");
if (expireDateStr != null && ![Link]()) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date utilDate = [Link](expireDateStr);
[Link](new [Link]([Link]()));
} else {
[Link](null);
}
// Set salePrice with null check
String salePriceStr = [Link]("salePrice");
if (salePriceStr != null && ![Link]().isEmpty()) {
try {
[Link]([Link](salePriceStr));
} catch (NumberFormatException e) {
[Link](0); // Set default sale price
}
} else {
[Link](0); // Set default sale price
}
// Set stock with null check
St i g t kSt t g tP t (" t k")
String stockStr = [Link]("stock");
if (stockStr != null && ![Link]().isEmpty()) {
try {
[Link]([Link](stockStr));
} catch (NumberFormatException e) {
[Link](0); // Set default stock
}
} else {
[Link](0); // Set default stock
}
// Set age range (can be null)
String[] ageRanges = [Link]("ageRange");
if (ageRanges != null && [Link] > 0) {
[Link]([Link](",", ageRanges));
} else {
[Link](null);
}
// Handle image upload
Part imagePart = [Link]("image");
if (imagePart != null && [Link]() > 0) {
InputStream is = [Link]();
[Link]([Link]());
} else if ([Link]("keepImage") != null) {
// Keep existing image if checkbox is checked (for edit mode)
String idParam = [Link]("id");
if (idParam != null && ![Link]().isEmpty()) {
try {
int productId = [Link](idParam);
Product existing = [Link](productId);
if (existing != null) {
[Link]([Link]());
}
} catch (NumberFormatException e) {
// Invalid ID, do nothing - new product will have no image
}
}
}
}
}
skintest> SaveSkinResultServlet1
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@SuppressWarnings("serial")
public class SaveSkinResultServlet1 extends HttpServlet {
private Connection getConnection() throws SQLException {
String url = "jdbc:mysql://localhost:3306/skincare";
String user = "root";
String password = "root";
return [Link](url, user, password);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
int brightness = [Link]([Link]("brightness"));
int oiliness = [Link]([Link]("oiliness"));
int redness = [Link]([Link]("redness"));
int texture = [Link]([Link]("texture"));
int poreCount = [Link]([Link]("poreCount"));
String skinType = [Link]("skinType");
// ✅ LoginServlet ထဲမှာထည့်ထားတဲ့ userUid ကို session ထဲကနေယူ
HttpSession session = [Link](false);
Integer uid = (session != null) ? (Integer) [Link]("userUid") : null;
if (uid == null) {
[Link]("[Link]");
return;
}
try (Connection conn = getConnection()) {
// ✅ uid ထည့်သွားမယ့် query
String sql = "INSERT INTO skin_result (uid, brightness, oiliness, redness, texture, pore_count,
skin_type) " +
"VALUES (?, ?, ?, ?, ?, ?, ?)";
PreparedStatement stmt = [Link](sql);
[Link](1, uid);
[Link](2, brightness);
[Link](3, oiliness);
t t tI t(4 d )
[Link](4, redness);
[Link](5, texture);
[Link](6, poreCount);
[Link](7, skinType);
[Link]();
} catch (SQLException e) {
[Link]();
}
// ✅ userUid ကို forward ချင်ရင် session ထဲထပ် save လိုက်မယ်
[Link]("userUid", uid);
[Link]("[Link]");
}
}
webapp> js> [Link] [ its a long file i will share you separatly]
META-INF > [Link]
Manifest-Version: 1.0
Class-Path:
WEB-INF > [Link] >
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="[Link]
xmlns:xsi="[Link]
xsi:schemaLocation="[Link]
[Link]
version="5.0">
<servlet>
<servlet-name>SendOTPServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SendOTPServlet</servlet-name>
<url-pattern>/SendOTPServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>VerifyOTPServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>VerifyOTPServlet</servlet-name>
<url-pattern>/VerifyOTPServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ResetPasswordServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ResetPasswordServlet</servlet-name>
<url-pattern>/ResetPasswordServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>LogoutServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LogoutServlet</servlet-name>
<url-pattern>/LogoutServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ForgotpasswordVerifyOTPServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ForgotpasswordVerifyOTPServlet</servlet-name>
<url-pattern>/ForgotpasswordVerifyOTPServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ForgotpasswordSendOTPServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ForgotpasswordSendOTPServlet</servlet-name>
<url-pattern>/ForgotpasswordSendOTPServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>UploadPhotoServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UploadPhotoServlet</servlet-name>
<url-pattern>/UploadPhotoServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>DisplayPhotoServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DisplayPhotoServlet</servlet-name>
<url-pattern>/DisplayPhotoServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>UpdateAccountServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UpdateAccountServlet</servlet-name>
<url-pattern>/UpdateAccountServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>PhotoServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>PhotoServlet</servlet-name>
<url-pattern>/photo</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>LoadMessagesServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoadMessagesServlet</servlet-name>
<url-pattern>/LoadMessagesServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>SendMessageServlet2</servlet-name>
<servlet-class>[Link].SendMessageServlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SendMessageServlet2</servlet-name>
<url-pattern>/SendMessageServlet2</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>UpdagePhotoServletAdmin</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UpdagePhotoServletAdmin</servlet-name>
<url-pattern>/UpdagePhotoServletAdmin</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>SendMessageServlet3</servlet-name>
<servlet-class>[Link].SendMessageServlet3</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SendMessageServlet3</servlet-name>
<url-pattern>/SendMessageServlet3</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>SaveSkinResultServlet1</servlet-name>
<servlet-class>[Link].SaveSkinResultServlet1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SaveSkinResultServlet1</servlet-name>
<url-pattern>/SaveSkinResultServlet1</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>BrandServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BrandServlet</servlet-name>
<url-pattern>/BrandServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>CategoryServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CategoryServlet</servlet-name>
<url-pattern>/CategoryServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ProductServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ProductServlet</servlet-name>
<url-pattern>/ProductServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ConfirmOrderServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ConfirmOrderServlet</servlet-name>
<url-pattern>/singleOrder</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>BatchOrderServlet</servlet-name>
<servlet-class>[Link]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BatchOrderServlet</servlet-name>
<url-pattern>/batchOrder</url-pattern>
</servlet-mapping>
</web-app>
[Link] >
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="[Link].*, [Link]" %>
<%
String email = (String) [Link]("userEmail");
if(email == null){
[Link]("[Link]");
return;
String name="", address="";
byte[] photoBytes = null;
try(Connection conn = [Link]()){
PreparedStatement ps = [Link]("SELECT name, email_phone, address, photo FROM
user WHERE email_phone=?");
[Link](1, email);
ResultSet rs = [Link]();
if([Link]()){
name = [Link]("name");
address = [Link]("address");
photoBytes = [Link]("photo");
} catch(Exception e){
[Link]();
String photoBase64 = "";
if(photoBytes != null){
photoBase64 = [Link]().encodeToString(photoBytes);
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Account Information</title>
<link rel="stylesheet" href="[Link]
<style>
* { margin: 0; padding: 0; box-sizing: border-box; font-family: "Poppins", sans-serif; }
body { background: #f5f6fa; display: flex; height: 100vh; }
/* Sidebar */
.sidebar {
width: 260px;
background: linear-gradient(180deg, #8dddf7, #63b9d6);
padding: 20px;
box-shadow: 4px 0 15px rgba(0,0,0,0.2);
display: flex;
flex-direction: column;
color: #fff;
border-radius: 0 20px 20px 0;
/* Profile */
.profile { text-align: center; margin-bottom: 30px; }
.profile h3 { margin-bottom: 8px; font-size: 18px; font-weight: 600; color: #fff; text-shadow: 1px 1px 3px
rgba(0,0,0,0.4); }
/* Photo Container */
.photo-container {
position: relative; display: inline-block;
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
border-radius: 50%;
.photo-container img {
width: 90px; height: 90px; border-radius: 50%;
border: 3px solid #fff; object-fit: cover;
transition: transform 0.3s, box-shadow 0.3s;
}
.photo-container img:hover { transform: scale(1.05); box-shadow: 0 6px 15px rgba(0,0,0,0.4); }
/* Upload Button */
.upload-btn {
position: absolute; bottom: 0; right: 0;
background: linear-gradient(to right, #ff5f6d, #ffc371);
color: white; width: 28px; height: 28px;
border-radius: 50%; text-align: center;
line-height: 28px; font-size: 20px; cursor: pointer;
box-shadow: 0 3px 6px rgba(0,0,0,0.3);
transition: transform 0.2s;
.upload-btn:hover { transform: scale(1.2); }
/* Logout Button */
.logout-btn {
padding: 10px 16px;
background: linear-gradient(to right, #ff416c, #ff4b2b);
color: #fff; border: none; border-radius: 12px;
cursor: pointer; font-size: 14px; font-weight: 600;
margin-top: auto; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
transition: transform 0.2s;
.logout-btn:hover { transform: scale(1.05); }
/* Menu */
.menu { margin-top: 20px; flex: 1; }
.menu a {
display: flex; align-items: center;
text-decoration: none;
color: #fff; padding: 12px;
border-radius: 12px;
margin-bottom: 12px;
font-size: 15px; font-weight: 500;
transition: 0.3s;
background: rgba(255,255,255,0.05);
box-shadow: 0 2px 6px rgba(0,0,0,0.15);
.menu a:hover {
background: rgba(255,255,255,0.2);
transform: translateX(5px);
.menu [Link] {
background: linear-gradient(90deg, #ff5f6d, #ffc371);
color: #fff;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
.menu a i { margin-right: 12px; font-size: 18px; color: #fff; }
/* Main Content */
.main {
flex: 1;
padding: 40px;
background-color: #f4f6f9;
color: #2c3e50;
border-radius: 20px 0 0 20px;
background: url("images/[Link]") no-repeat center center/cover;
/* Account Box */
.account-box {
max-width: 550px;
margin: auto;
padding: 35px;
border-radius: 20px;
background: linear-gradient(145deg, #ffffff, #f0f0f5);
box-shadow: 0 8px 20px rgba(0,0,0,0.15);
border-top: 6px solid #8e2de2;
.account-box h2 {
text-align: center;
margin-bottom: 25px;
font-size: 22px;
font-weight: 700;
color: #4a00e0;
/* Photo Display */
.photo-display {
text-align: center;
margin-bottom: 20px;
position: relative;
.photo-display img {
width: 120px; height: 120px;
border-radius: 50%;
border: 3px solid #4a00e0;
object-fit: cover;
box-shadow: 0 4px 10px rgba(0,0,0,0.25);
.photo-display .upload-btn {
bottom: 5px; right: calc(50% - 55px);
/* Fields */
.field { margin-bottom: 18px; }
.field label {
display: block;
margin-bottom: 6px;
font-weight: 600;
color: #4a00e0;
.field input {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 10px;
background: #fafafa;
color: #333;
font-size: 14px;
.field input:disabled {
background: #ececec;
color: #777;
/* Button */
.update-btn {
width: 100%;
padding: 14px;
border: none;
border-radius: 12px;
background: linear-gradient(to right,#8e2de2,#4a00e0);
color: white;
font-weight: 600;
cursor: pointer;
font-size: 15px;
transition: 0.3s;
}
.update-btn:hover {
opacity: 0.9;
transform: translateY(-2px);
</style>
</head>
<body>
<div class="sidebar">
<div class="profile">
<div class="photo-container">
<img src="DisplayPhotoServlet" alt="User" id="profileImg">
<form action="UploadPhotoServlet" method="post" enctype="multipart/form-data"
id="uploadForm">
<label for="photoInputSidebar" class="upload-btn">+</label>
<input type="file" name="photo" id="photoInputSidebar" accept="image/*" style="display:none;"
onchange="[Link]('uploadForm').submit();">
</form>
</div>
<br><br>
<h3><%= name %></h3>
</div>
<div class="menu">
<a href="#" ><i class="fa-solid fa-box"></i> My Orders</a>
<a href="#"><i class="fa-solid fa-ban"></i> My Cancellation</a>
<a href="#"><i class="fa-solid fa-star"></i> My Reviews</a>
<a href="[Link]" class="active"><i class="fa-solid fa-user"></i> Account Information</a>
<a href="#"><i class="fa-solid fa-palette"></i> Skin-Test Results</a>
<a href="[Link]"><i class="fa-solid fa-comments"></i> Chat</a>
</div>
<button class="logout-btn" onclick="[Link]='LogoutServlet'">Log Out</button>
</div>
<div class="main">
<div class="account-box">
<h2>Account Information</h2>
<form action="UpdateAccountServlet" method="post" enctype="multipart/form-data">
<div class="photo-display">
<img src="<%= ([Link]() ? "images/[Link]" : "data:image/jpeg;base64," +
photoBase64) %>" alt="Profile Photo">
<label for="photoInputMain" class="upload-btn">+</label>
<input type="file" name="photo" id="photoInputMain" style="display:none;"
onchange="[Link]();">
</div>
<div class="field">
<label>Name</label>
<input type="text" name="name" value="<%= name %>">
</div>
<div class="field">
<label>Email / Phone</label>
<input type="text" value="<%= email %>" disabled>
</div>
<div class="field">
<label>Address</label>
<input type="text" name="address" value="<%= address %>">
</div>
<button type="submit" class="update-btn">Update Account</button>
</form>
</div>
</div>
<script>
const links = [Link]('.menu a');
[Link](link => {
[Link]('click', () => {
[Link](l => [Link]('active'));
[Link]('active');
});
});
</script>
</body>
</html>
[Link] >
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="[Link].*, [Link]" %>
<%
String myEmail = (String) [Link]("userEmail");
String myName = (String) [Link]("userName");
String myRole = (String) [Link]("userRole");
if (myEmail == null || myRole == null || !"ADMIN".equals(myRole)) {
[Link]("[Link]");
return;
if(myEmail != null && myName == null){
try(Connection conn = [Link]()){
PreparedStatement ps = [Link]("SELECT name FROM user WHERE
email_phone=?");
[Link](1, myEmail);
ResultSet rs = [Link]();
if([Link]()){
myName = [Link]("name");
[Link]("userName", myName);
} catch(Exception e){
[Link]();
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Messenger</title>
<link href="[Link] rel="stylesheet">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; font-family: "Poppins", sans-serif; }
body { background: #f5f6fa; display: flex; height: 100vh; }
/* Sidebar */
.sidebar {
width: 260px;
background: linear-gradient(180deg, #8e2de2, #4a00e0);
padding: 20px;
box-shadow: 4px 0 15px rgba(0,0,0,0.2);
display: flex;
flex-direction: column;
color: #fff;
border-radius: 0 20px 20px 0;
/* Profile */
.profile { text-align: center; margin-bottom: 30px; }
.profile h3 { margin-bottom: 8px; font-size: 18px; font-weight: 600; color: #fff; text-shadow: 1px 1px 3px
rgba(0,0,0,0.4); }
/* Photo Container */
.photo-container {
position: relative; display: inline-block;
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
border-radius: 50%;
.photo-container img {
width: 90px; height: 90px; border-radius: 50%;
border: 3px solid #fff; object-fit: cover;
transition: transform 0.3s, box-shadow 0.3s;
.photo-container img:hover { transform: scale(1.05); box-shadow: 0 6px 15px rgba(0,0,0,0.4); }
/* Upload Button */
.upload-btn {
position: absolute; bottom: 0; right: 0;
background: linear-gradient(to right, #ff5f6d, #ffc371);
color: white; width: 28px; height: 28px;
border-radius: 50%; text-align: center;
line-height: 28px; font-size: 20px; cursor: pointer;
box-shadow: 0 3px 6px rgba(0,0,0,0.3);
transition: transform 0.2s;
.upload-btn:hover { transform: scale(1.2); }
/* Logout Button */
.logout-btn {
padding: 10px 16px;
background: linear-gradient(to right, #ff416c, #ff4b2b);
color: #fff; border: none; border-radius: 12px;
cursor: pointer; font-size: 14px; font-weight: 600;
margin-top: auto; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
transition: transform 0.2s;
.logout-btn:hover { transform: scale(1.05); }
/* Menu */
.menu { margin-top: 20px; flex: 1; }
.menu a {
display: flex; align-items: center;
text-decoration: none;
color: #fff; padding: 12px;
border-radius: 12px;
margin-bottom: 12px;
font-size: 15px; font-weight: 500;
transition: 0.3s;
background: rgba(255,255,255,0.05);
box-shadow: 0 2px 6px rgba(0,0,0,0.15);
.menu a:hover {
background: rgba(255,255,255,0.2);
transform: translateX(5px);
.menu [Link] {
background: linear-gradient(90deg, #ff5f6d, #ffc371);
color: #fff;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
.menu a i { margin-right: 12px; font-size: 18px; color: #fff; }
/* Main Content */
</style>
</head>
<body>
<div class="sidebar">
<div class="profile">
<div class="photo-container">
<img src="DisplayPhotoServlet" alt="User" id="profileImg">
<form action="UpdagePhotoServletAdmin" method="post" enctype="multipart/form-data"
id="uploadForm">
<label for="photoInput" class="upload-btn">+</label>
<input type="file" name="photo" id="photoInput" accept="image/*" style="display:none;"
onchange="[Link]('uploadForm').submit();">
</form>
</div>
<br><br>
<h3><%= myName %></h3>
</div>
<div class="menu">
<a href="#" class="active"><i class="fa-solid fa-box"></i>a</a>
<a href="[Link]"><i class="fa-solid fa-ban"></i> skin results</a>
<a href="#"><i class="fa-solid fa-star"></i> c</a>
<a href=""><i class="fa-solid fa-user"></i> d</a>
<a href="#"><i class="fa-solid fa-palette"></i> e</a>
<a href="[Link]" ><i class="fa-solid fa-comments"></i> Chat</a>
</div>
<button class="logout-btn" onclick="[Link]='LogoutServlet'">Log Out</button>
</div>
<div class="main">
</div>
<script>
const links = [Link]('.menu a');
[Link](link => {
[Link]('click', () => {
[Link](l => [Link]('active'));
[Link]('active');
});
});
</script>
</body>
</html>
[Link] >
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="[Link].*, [Link]" %>
<%
String myEmail = (String) [Link]("userEmail");
String myName = (String) [Link]("userName");
String myRole = (String) [Link]("userRole");
if (myEmail == null || myRole == null || !"ADMIN".equals(myRole)) {
[Link]("[Link]");
return;
String chatWith = [Link]("with");
String otherName = "";
if (chatWith != null) {
try (Connection con = [Link]();
PreparedStatement ps = [Link]("SELECT name FROM user WHERE email_phone=?"))
{
[Link](1, chatWith);
ResultSet rs = [Link]();
if ([Link]()) otherName = [Link]("name");
} catch (Exception e) { [Link](); }
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Admin Chat</title>
<link href="[Link] rel="stylesheet">
<link href="[Link] rel="stylesheet">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; font-family: "Poppins", sans-serif; }
body { background: #f5f6fa; display: flex; height: 100vh; }
/* Sidebar */
.sidebar {
width: 260px;
background: linear-gradient(180deg, #8e2de2, #4a00e0);
padding: 20px;
box-shadow: 4px 0 15px rgba(0,0,0,0.2);
display: flex;
flex-direction: column;
color: #fff;
border-radius: 0 20px 20px 0;
/* Profile */
.profile { text-align: center; margin-bottom: 30px; }
.profile h3 { margin-bottom: 8px; font-size: 18px; font-weight: 600; color: #fff; text-shadow: 1px 1px 3px
rgba(0,0,0,0.4); }
/* Photo Container */
.photo-container {
position: relative; display: inline-block;
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
border-radius: 50%;
.photo-container img {
width: 90px; height: 90px; border-radius: 50%;
border: 3px solid #fff; object-fit: cover;
transition: transform 0.3s, box-shadow 0.3s;
.photo-container img:hover { transform: scale(1.05); box-shadow: 0 6px 15px rgba(0,0,0,0.4); }
/* Upload Button */
.upload-btn {
position: absolute; bottom: 0; right: 0;
background: linear-gradient(to right, #ff5f6d, #ffc371);
color: white; width: 28px; height: 28px;
border-radius: 50%; text-align: center;
line-height: 28px; font-size: 20px; cursor: pointer;
box-shadow: 0 3px 6px rgba(0,0,0,0.3);
transition: transform 0.2s;
.upload-btn:hover { transform: scale(1.2); }
/* Logout Button */
.logout-btn {
padding: 10px 16px;
background: linear-gradient(to right, #ff416c, #ff4b2b);
color: #fff; border: none; border-radius: 12px;
cursor: pointer; font-size: 14px; font-weight: 600;
margin-top: auto; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
transition: transform 0.2s;
.logout-btn:hover { transform: scale(1.05); }
/* Menu */
.menu { margin-top: 20px; flex: 1; }
.menu a {
display: flex; align-items: center;
text-decoration: none;
color: #fff; padding: 12px;
border-radius: 12px;
margin-bottom: 12px;
font-size: 15px; font-weight: 500;
transition: 0.3s;
background: rgba(255,255,255,0.05);
box-shadow: 0 2px 6px rgba(0,0,0,0.15);
.menu a:hover {
background: rgba(255,255,255,0.2);
transform: translateX(5px);
.menu [Link] {
background: linear-gradient(90deg, #ff5f6d, #ffc371);
color: #fff;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
.menu a i { margin-right: 12px; font-size: 18px; color: #fff; }
/* Right Content (User list + Chat) */
.right-content{flex:1;display:flex;}
/* User List Sidebar */
.user-sidebar{width:280px;background:#fff;border-right:1px solid #ddd;overflow-y:auto;padding:15px;}
.user-card{display:flex;align-items:center;gap:10px;padding:10px;border-radius:8px;text-
decoration:none;color:#333;margin-bottom:8px;}
.user-card:hover{background:#f1f1f1;}
.user-card img{width:35px;height:35px;border-radius:50%;object-fit:cover;}
.user-info{flex:1;}
.user-info .name{font-weight:600;font-size:14px;}
.user-info .email{font-size:12px;color:#777;}
/* Chat Area */
.chat-area{flex:1;display:flex;flex-direction:column;}
.chat-header{padding:12px 16px;background:linear-
gradient(45deg,#8e2de2,#4a00e0);color:#fff;display:flex;align-items:center;gap:10px;}
.chat-header img{width:40px;height:40px;border-radius:50%;object-fit:cover;}
.messages{flex:1;overflow:auto;padding:15px;background:#f9f9fb;}
.bubble-row{display:flex;margin:6px 0;}
.bubble{max-width:70%;padding:10px 14px;border-radius:16px;font-size:14px;}
.me{justify-content:flex-end;}
.[Link]{background:#4a61ff;color:#fff;}
.[Link]{background:#eee;}
.inputbar{display:flex;gap:8px;padding:10px;border-top:1px solid #ddd;background:#fff;}
.inputbar input{flex:1;padding:10px;border-radius:20px;border:1px solid #ccc;}
.inputbar button{border:none;background:#4a61ff;color:#fff;border-radius:20px;padding:10px
16px;cursor:pointer;}
.emoji-btn{width:42px;border:1px solid #ddd;background:#fff;border-radius:20px;}
.emoji-panel{ display:none; position:absolute; bottom:60px; right:16px; background:#fff; border:1px solid
#e5e5e5; border-radius:12px; padding:8px; box-shadow:0 8px 24px rgba(0,0,0,.12); width:260px; max-
height:220px; overflow:auto; z-index:10;}
.[Link]{ display:block; }
.emoji-panel button{ font-size:20px; padding:6px; border:none; background:transparent; cursor:pointer;
border-radius:8px; }
.emoji-panel button:hover{ background:#f5f5f5; }
</style>
</head>
<body>
<div class="sidebar">
<div class="profile">
<div class="photo-container">
<img src="DisplayPhotoServlet" alt="User" id="profileImg">
<form action="UpdagePhotoServletAdmin" method="post" enctype="multipart/form-data"
id="uploadForm">
<label for="photoInput" class="upload-btn">+</label>
<input type="file" name="photo" id="photoInput" accept="image/*" style="display:none;"
onchange="[Link]('uploadForm').submit();">
</form>
</div>
<br><br>
<h3><%= myName %></h3>
</div>
<div class="menu">
<a href="#" ><i class="fa-solid fa-box"></i>a</a>
<a href="#"><i class="fa-solid fa-ban"></i> b</a>
<a href="#"><i class="fa-solid fa-star"></i> c</a>
<a href=""><i class="fa-solid fa-user"></i> d</a>
<a href="#"><i class="fa-solid fa-palette"></i> e</a>
<a href="[Link]" class="active" ><i class="fa-solid fa-comments"></i> Chat</a>
</div>
<button class="logout-btn" onclick="[Link]='LogoutServlet'">Log Out</button>
</div>
<!-- Right Content Area (User List + Chatbox) -->
<div class="right-content">
<!-- User Sidebar -->
<div class="user-sidebar">
<h5>Users</h5>
<%
try(Connection con = [Link]();
PreparedStatement ps = [Link]("SELECT email_phone, name FROM user WHERE
role='USER'")) {
ResultSet rs = [Link]();
while([Link]()){
String uEmail = [Link]("email_phone");
String uName = [Link]("name");
%>
<a href="[Link]?with=<%=uEmail%>" class="user-card">
<img src="photo?email=<%= uEmail %>" alt="user">
<div class="user-info">
<div class="name"><%= uName %></div>
<div class="email"><%= uEmail %></div>
</div>
</a>
<%
} catch(Exception e){ [Link]("<div class='text-danger'>"+[Link]()+"</div>"); }
%>
</div>
<!-- Chatbox -->
<div class="chat-area">
<% if(chatWith != null){ %>
<div class="chat-header">
<img src="photo?email=<%= chatWith %>" />
<div>
<div><%= otherName %></div>
<small>online</small>
</div>
</div>
<div id="msgs" class="messages"></div>
<form class="inputbar" action="<%= [Link]() %>/SendMessageServlet3"
method="post">
<button type="button" id="emojiBtn" class="emoji-btn"> 😊</button>
<input type="hidden" name="receiver" value="<%= chatWith %>"/>
<input id="msgInput" type="text" name="message" placeholder="Write a message…" required/>
<button type="submit">Send</button>
<div id="emojiPanel" class="emoji-panel">
😀
<button> </button><button> 😁</button><button>😂</button><button>🤣</button><button>😊
</button>
😍
<button> </button><button> 😘</button><button>😎</button><button>🤩</button><button>🤔
</button>
👏
<button> </button><button> 👍</button><button>🙏</button><button>🔥</button>
💯
<button> </button>
🎉
<button> </button><button> 🥳</button><button>✅</button><button>❗</button>
✨
<button> </button>
</div>
</form>
<% } else { %>
<div style="flex:1;display:flex;align-items:center;justify-content:center;color:#777;">
👈 Select a user to start chatting
</div>
<% } %>
</div>
</div>
<script>
const links = [Link]('.menu a');
[Link](link => {
[Link]('click', () => {
[Link](l => [Link]('active'));
[Link]('active');
});
});
</script>
<script>
function insertAtCursor(input,text){
const start=[Link],end=[Link],val=[Link];
[Link]=[Link](0,start)+text+[Link](end);
[Link](start+[Link],start+[Link]);
[Link]();
function setupEmojiPicker(btnId,panelId,inputId){
const
btn=[Link](btnId),panel=[Link](panelId),input=[Link]
mentById(inputId);
if(!btn) return;
[Link]('click',()=>[Link]('show'));
[Link]('button').forEach(b=>{
[Link]('click',()=>{ insertAtCursor(input,[Link]); [Link]('show'); });
});
[Link]('click',(e)=>{ if(&&[Link]!==btn)
[Link]('show'); });
setupEmojiPicker('emojiBtn','emojiPanel','msgInput');
const otherEmail="<%= chatWith %>";
const msgs=[Link]('msgs');
function fetchHTML(url,cb){ const xhr=new XMLHttpRequest(); [Link]('GET',url,true); [Link]=
()=>cb([Link]); [Link](); }
function refreshMessages(){ if(otherEmail && msgs){ fetchHTML('LoadMessagesServlet?
with='+encodeURIComponent(otherEmail),(html)=>{ [Link]=html;
[Link]=[Link]; }); } }
setInterval(refreshMessages,1500); [Link]=refreshMessages;
</script>
</body>
</html>
[Link] >
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ page
import="[Link].*,[Link],[Link],[Link],java.
[Link]" %>
<%@ page import="[Link]" %>
<%
String role = null;
Integer uid = null;
Cookie[] cookies = [Link]();
if (cookies != null) {
for (Cookie c : cookies) {
if ("userRole".equals([Link]())) role = [Link]();
if ("userUid".equals([Link]())) uid = [Link]([Link]());
// Admin sees everything, customer sees only own orders
if (!"ADMIN".equalsIgnoreCase(role) && uid == null) {
[Link]("[Link]");
return;
OrderDAO dao = new OrderDAO();
List<OrderDetail> orders = [Link]("ADMIN".equalsIgnoreCase(role) ? null : uid);
NumberFormat nf = [Link]();
%>
<!DOCTYPE html>
<html>
<head>
<title>All Orders</title>
<link href="[Link] rel="stylesheet">
</head>
<body class="bg-light">
<div class="container py-5">
<h2 class="mb-4"><%= "USER".equalsIgnoreCase(role) ?"My Orders" :"All Orders (Admin)" %></h2>
<% if ([Link]()) { %>
<div class="alert alert-info">No orders found.</div>
<% } else { %>
<% for (OrderDetail od : orders) { %>
<div class="card mb-4">
<div class="card-header">
Order #<%= [Link]() %> – <%= [Link]() %>
<% if (uid == null) { %>
<span class="badge bg-secondary ms-2"><%= [Link]() %></span>
<% } %>
</div>
<div class="card-body">
<p><strong>Address:</strong><br><%= [Link]() %></p>
<p><strong>Phone:</strong> <%= [Link]() %></p>
<table class="table table-sm">
<thead><tr><th>Product</th><th>Qty</th><th>Price</th><th>Subtotal</th></tr></thead>
<tbody>
<% for (OrderItem oi : [Link]()) { %>
<tr>
<td><%= [Link]() %></td>
<td><%= [Link]() %></td>
<td><%= [Link]([Link]()) %> MMK</td>
<td><%= [Link]([Link]() * [Link]()) %> MMK</td>
</tr>
<% } %>
</tbody>
<tfoot>
<tr class="table-info">
<th colspan="3">Grand Total</th>
<th><%= [Link]([Link]()) %> MMK</th>
</tr>
</tfoot>
</table>
</div>
</div>
<% } %>
<% } %>
</div>
</body>
</html>
[Link] >
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="[Link], [Link]" %>
<%@ page import="[Link]" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Brand Management</title>
<link href="[Link] rel="stylesheet" />
<link rel="stylesheet" href="[Link]
[Link]">
<style>
:root {
--primary-color: #4361ee;
--success-color: #2e7d32;
--danger-color: #dc3545;
--warning-color: #ffc107;
--hover-transition: all 0.3s ease;
body {
background-color: #f8f9fa;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
.container {
max-width: 1200px;
.page-title {
margin-bottom: 2rem;
color: var(--success-color);
font-weight: 600;
text-shadow: 0 2px 4px rgba(0,0,0,0.05);
/* Card Styles */
.brand-card {
height: 100%;
transition: var(--hover-transition);
border-radius: 10px;
overflow: hidden;
position: relative;
}
.brand-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
.card-img-container {
height: 200px;
background-color: #f1f3f5;
display: flex;
align-items: center;
justify-content: center;
.card-img {
max-height: 100%;
max-width: 100%;
object-fit: contain;
padding: 1rem;
.card-body {
padding: 1.25rem;
.brand-name {
font-weight: 600;
color: #212529;
margin-bottom: 0;
}
/* Action Buttons */
.action-buttons {
position: absolute;
top: 10px;
right: 10px;
display: flex;
gap: 5px;
opacity: 0;
transition: var(--hover-transition);
z-index: 10;
.brand-card:hover .action-buttons {
opacity: 1;
.action-btn {
width: 30px;
height: 30px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
color: white;
border: none;
transition: var(--hover-transition);
.delete-btn {
background-color: var(--danger-color);
}
.delete-btn:hover {
background-color: #bd2130;
transform: scale(1.1);
.edit-btn {
background-color: var(--warning-color);
.edit-btn:hover {
background-color: #e0a800;
transform: scale(1.1);
/* Add Brand Card */
.add-brand-card {
border: 2px dashed #adb5bd;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
min-height: 300px;
transition: var(--hover-transition);
background-color: rgba(233, 236, 239, 0.5);
.add-brand-card:hover {
background-color: rgba(233, 236, 239, 0.8);
border-color: var(--primary-color);
}
.add-brand-content {
text-align: center;
color: #6c757d;
.add-brand-icon {
font-size: 3rem;
margin-bottom: 1rem;
color: var(--primary-color);
/* No Brands State */
.no-brands-container {
min-height: 300px;
display: flex;
align-items: center;
justify-content: center;
background-color: #f8f9fa;
border-radius: 10px;
/* Search Styles */
.search-container {
margin: 2rem auto;
max-width: 600px;
position: relative;
.search-input {
padding: 0.75rem 1.5rem 0.75rem 3rem;
border-radius: 50px;
border: 1px solid #dee2e6;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
width: 100%;
transition: var(--hover-transition);
background-image: url("data:image/svg+xml,%3Csvg xmlns='[Link] width='16'
height='16' fill='%236c757d' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397
1.398h-.001c.[Link].098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0
0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: 1rem center;
background-size: 1rem;
.search-input:focus {
border-color: var(--primary-color);
box-shadow: 0 4px 6px rgba(67, 97, 238, 0.15);
outline: none;
/* Modal Styles */
.modal-header {
background-color: var(--success-color);
color: white;
/* Edit Modal Header */
#editBrandModal .modal-header {
background-color: var(--warning-color);
}
/* Delete Confirmation Modal */
#deleteConfirmModal .modal-header {
background-color: var(--danger-color);
/* Toast Notification */
.toast-container {
position: fixed;
top: 20px;
right: 20px;
z-index: 9999;
/* Responsive Adjustments */
@media (max-width: 768px) {
.card-img-container {
height: 150px;
.page-title {
font-size: 1.75rem;
.action-buttons {
opacity: 1; /* Always show on mobile */
/* Current logo preview */
.current-logo-preview {
max-height: 120px;
max-width: 100%;
margin-top: 10px;
border: 1px solid #dee2e6;
border-radius: 5px;
padding: 5px;
</style>
</head>
<body class="bg-light">
<div class="container py-5">
<h1 class="page-title text-center">Brand Management</h1>
<!-- Search Section -->
<div class="search-container">
<input type="search"
id="searchInput"
class="form-control search-input"
placeholder="Search brands by name..."
aria-label="Search brands">
</div>
<!-- Toast Notification Container -->
<div class="toast-container"></div>
<!-- Error Message Display -->
<%
String error = (String) [Link]("error");
String success = (String) [Link]("success");
if (error != null && ![Link]()) {
%>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<%= error %>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<% } %>
<% if (success != null && ![Link]()) { %>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<%= success %>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<% } %>
<div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-4">
<%
BrandDAO brandDAO = new BrandDAO();
List<Brand> brandList = [Link]();
Brand editBrand = (Brand) [Link]("editBrand");
if (brandList != null && ![Link]()) {
for (Brand brand : brandList) {
String base64Image = [Link]();
%>
<div class="col">
<div class="brand-card card shadow-sm">
<!-- Action Buttons -->
<div class="action-buttons">
<button class="action-btn edit-btn"
data-bs-toggle="modal"
data-bs-target="#editBrandModal"
data-brand-id="<%= [Link]() %>"
data-brand-name="<%= [Link]() %>"
data-brand-image="<%= base64Image != null ? base64Image : "" %>">
<i class="bi bi-pencil"></i>
</button>
<button class="action-btn delete-btn"
data-bs-toggle="modal"
data-bs-target="#deleteConfirmModal"
data-brand-id="<%= [Link]() %>"
data-brand-name="<%= [Link]() %>">
<i class="bi bi-x-lg"></i>
</button>
</div>
<div class="card-img-container">
<% if (base64Image != null && ![Link]()) { %>
<img src="data:image/jpeg;base64,<%= base64Image %>"
class="card-img"
alt="<%= [Link]() %> logo" />
<% } else { %>
<div class="text-muted">No Image Available</div>
<% } %>
</div>
<div class="card-body text-center">
<h3 class="brand-name"><%= [Link]() %></h3>
</div>
</div>
</div>
<%
} else {
%>
<div class="col-12">
<div class="no-brands-container card shadow-sm">
<div class="text-center p-5">
<i class="bi bi-box-seam display-4 text-muted mb-3"></i>
<h4 class="text-muted">No brands found</h4>
<p class="text-muted">Click the button below to add your first brand</p>
<button class="btn btn-success mt-3"
data-bs-toggle="modal"
data-bs-target="#addBrandModal">
Add Brand
</button>
</div>
</div>
</div>
<% } %>
<!-- Add Brand Card -->
<div class="col">
<div class="add-brand-card card"
data-bs-toggle="modal"
data-bs-target="#addBrandModal">
<div class="add-brand-content">
<div class="add-brand-icon">+</div>
<h5>Add New Brand</h5>
</div>
</div>
</div>
</div>
</div>
<!-- Add Brand Modal -->
<div class="modal fade" id="addBrandModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<form class="modal-content"
action="BrandServlet"
method="post"
enctype="multipart/form-data">
<div class="modal-header">
<h5 class="modal-title">Add New Brand</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label for="name" class="form-label">Brand Name</label>
<input type="text"
class="form-control"
id="name"
name="name"
placeholder="Enter brand name"
required />
</div>
<div class="mb-3">
<label for="logo" class="form-label">Brand Logo</label>
<input type="file"
class="form-control"
id="logo"
name="logo"
accept="image/jpeg,image/png"
required />
<div class="form-text">Accepted formats: JPG, PNG (Max 5MB)</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-bs-
dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-success">Add Brand</button>
</div>
</form>
</div>
</div>
<!-- Edit Brand Modal -->
<div class="modal fade" id="editBrandModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<form class="modal-content"
action="BrandServlet"
method="post"
enctype="multipart/form-data">
<div class="modal-header">
<h5 class="modal-title">Edit Brand</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<input type="hidden" name="action" value="update">
<input type="hidden" name="id" id="editBrandId">
<div class="mb-3">
<label for="editName" class="form-label">Brand Name</label>
<input type="text"
class="form-control"
id="editName"
name="name"
placeholder="Enter brand name"
required />
</div>
<div class="mb-3">
<label for="editLogo" class="form-label">Brand Logo</label>
<input type="file"
class="form-control"
id="editLogo"
name="logo"
accept="image/jpeg,image/png" />
<div class="form-text">Leave empty to keep existing logo. Accepted formats: JPG, PNG (Max
5MB)</div>
<!-- Current logo display -->
<div class="mt-3">
<p class="mb-1 fw-bold">Current Logo:</p>
<div id="currentLogoContainer">
<img id="currentLogoImage" class="current-logo-preview" src="" alt="Current logo">
<p id="noLogoMessage" class="text-muted" style="display: none;">No logo available</p>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline-secondary" data-bs-
dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-warning">Update Brand</button>
</div>
</form>
</div>
</div>
<!-- Delete Confirmation Modal -->
<div class="modal fade" id="deleteConfirmModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Confirm Deletion</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Are you sure you want to delete the brand "<span id="brandNameToDelete"></span>"? This
action cannot be undone.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<form id="deleteForm" method="post" action="BrandServlet">
<input type="hidden" name="action" value="delete">
<input type="hidden" name="id" id="brandIdToDelete">
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</div>
</div>
</div>
</div>
<script src="[Link]
<script>
[Link]('DOMContentLoaded', function() {
// Search functionality
const searchInput = [Link]('searchInput');
if (searchInput) {
[Link]('input', function() {
const searchTerm = [Link]().trim();
const brandCards = [Link]('.brand-card');
[Link](card => {
const brandName = [Link]('.brand-name').[Link]();
const cardContainer = [Link]('.col');
if ([Link](searchTerm)) {
[Link] = 'block';
} else {
[Link] = 'none';
});
});
// Auto-focus search input when page loads
if (searchInput) {
[Link]();
// Delete brand modal setup
const deleteModal = [Link]('deleteConfirmModal');
if (deleteModal) {
[Link]('[Link]', function(event) {
const button = [Link];
const brandId = [Link]('data-brand-id');
const brandName = [Link]('data-brand-name');
[Link]('brandNameToDelete').textContent = brandName;
[Link]('brandIdToDelete').value = brandId;
});
// Edit brand modal setup
const editModal = [Link]('editBrandModal');
if (editModal) {
[Link]('[Link]', function(event) {
const button = [Link];
const brandId = [Link]('data-brand-id');
const brandName = [Link]('data-brand-name');
const brandImage = [Link]('data-brand-image');
// Set values in the form
[Link]('editBrandId').value = brandId;
[Link]('editName').value = brandName;
// Display current logo if available
const currentLogoImage = [Link]('currentLogoImage');
const noLogoMessage = [Link]('noLogoMessage');
if (brandImage && [Link] > 0) {
[Link] = "data:image/jpeg;base64," + brandImage;
[Link] = "block";
[Link] = "none";
} else {
[Link] = "none";
[Link] = "block";
});
// Auto-hide alerts after 5 seconds
const alerts = [Link]('.alert');
[Link](alert => {
setTimeout(() => {
const bsAlert = new [Link](alert);
[Link]();
}, 5000);
});
// If we're coming from an edit request with a brand to edit, open the modal
<% if (editBrand != null) { %>
// Create a button to trigger the modal
const triggerButton = [Link]('button');
[Link]('data-bs-toggle', 'modal');
[Link]('data-bs-target', '#editBrandModal');
[Link]('data-brand-id', '<%= [Link]() %>');
[Link]('data-brand-name', '<%= [Link]() %>');
[Link]('data-brand-image', '<%= [Link]() != null ? [Link]()
: "" %>');
[Link] = 'none';
[Link](triggerButton);
// Trigger the modal
const editModal = new [Link]([Link]('editBrandModal'));
[Link]();
// Clean up
setTimeout(() => {
[Link](triggerButton);
}, 1000);
<% } %>
});
</script>
<script>
// Notify parent frame that this page has loaded
[Link]({ type: 'PAGE_LOADED', pageName: 'Brand' }, '*');
</script>
</body>
</html>
[Link] >
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ page import="[Link].*,[Link].*,[Link]" %>
<%@ page import="[Link]" %>
<%
Integer uid = null;
Cookie[] cookies = [Link]();
if (cookies != null) {
for (Cookie c : cookies) {
if ("userUid".equals([Link]())) uid = [Link]([Link]());
if (uid == null) { [Link]("[Link]"); return; }
[Link](uid);
CartDAO dao = new CartDAO();
List<CartItem> items = [Link](uid);
%>
<!DOCTYPE html>
<html>
<head>
<title>My Cart</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="[Link] rel="stylesheet">
<style>
.card-img-sm { height: 160px; object-fit: cover; }
</style>
</head>
<body class="bg-light">
<div class="container py-5">
<h2 class="mb-4">Shopping Cart</h2>
<!-- Batch order button -->
<button class="btn btn-success mb-3" data-bs-toggle="modal" data-bs-target="#batchModal">
Order All Items
</button>
<div class="row g-4">
<% for (CartItem ci : items) { %>
<div class="col-md-4">
<div class="card">
<img src="data:image/jpeg;base64,<%= ci.getBase64Image() %>" class="card-img-sm" alt="<%=
[Link]() %>">
<div class="card-body">
<h5 class="card-title"><%= [Link]() %></h5>
<p class="card-text mb-1">Qty: <%= [Link]() %></p>
<p class="card-text mb-3">Price: <%=
[Link]().format([Link]()) %> MMK</p>
<!-- Button that opens the modal -->
<button class="btn btn-primary btn-sm confirmBtn"
data-pid="<%= [Link]() %>"
data-name="<%= [Link]() %>"
data-qty="<%= [Link]() %>">
Confirm Order
</button>
</div>
</div>
</div>
<% } %>
</div>
<!-- Single reusable modal -->
<div class="modal fade" id="orderModal" tabindex="-1">
<div class="modal-dialog">
<form id="singleOrderForm" action="${[Link]}/singleOrder"
method="post">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Order <span id="modalProductName"></span></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<input type="hidden" name="pid" id="modalPid">
<input type="hidden" name="qty" id="modalQty">
<div class="mb-3">
<label class="form-label">Delivery Address</label>
<textarea class="form-control" name="address" required></textarea>
</div>
<div class="mb-3">
<label class="form-label">Phone</label>
<input type="text" class="form-control" name="phone" required>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-success">Place Order</button>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- Batch order modal -->
<div class="modal fade" id="batchModal" tabindex="-1">
<div class="modal-dialog">
<form action="${[Link]}/batchOrder" method="post">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Order All Items</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label">Delivery Address</label>
<textarea class="form-control" name="address" required></textarea>
</div>
<div class="mb-3">
<label class="form-label">Phone</label>
<input type="text" class="form-control" name="phone" required>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">Confirm Batch Order</button>
</div>
</div>
</form>
</div>
</div>
<script src="[Link]
<script>
[Link]('.confirmBtn').forEach(btn => {
[Link]('click', () => {
[Link]('modalPid').value = [Link];
[Link]('modalQty').value = [Link];
[Link]('modalProductName').textContent = [Link];
new [Link]([Link]('orderModal')).show();
});
});
</script>
</body>
</html>
[Link] >
<%@ page import="[Link].*, [Link], [Link]" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
CategoryDAO dao = new CategoryDAO();
List<Category> categories = [Link]();
%>
<!DOCTYPE html>
<html>
<head>
<title>Category Management</title>
<link href="[Link] rel="stylesheet">
<style>
.search-container {
margin-bottom: 35px;
display: flex;
justify-content: center;
position: relative;
max-width: 800px;
margin-left: auto;
margin-right: auto;
#searchInput {
padding: 16px 25px 16px 60px;
border: 1px solid #ced4da;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
font-size: 1.15rem;
border-radius: 50px;
width: 100%;
transition: all 0.3s;
background: #fff;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="[Link] viewBox="0 0
24 24" fill="%236c757d" width="24px" height="24px"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11
16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-
4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>');
background-repeat: no-repeat;
background-position: 25px center;
background-size: 24px 24px;
#searchInput:focus {
box-shadow: 0 6px 20px rgba(67, 97, 238, 0.25);
border-color: #4361ee;
outline: none;
</style>
</head>
<body class="bg-light">
<div class="container mt-5">
<h2 class="text-center mb-4">Category Management</h2>
<% String msg = (String) [Link]("msg"); %>
<% if (msg != null) { %>
<div class="alert alert-info"><%= msg %></div>
<% } %>
<form action="CategoryServlet" method="post" class="card p-4 shadow-sm mb-4">
<div class="mb-3">
<label class="form-label">Category Name</label>
<input type="text" name="cgname" class="form-control" required />
</div>
<button type="submit" class="btn btn-success">Add Category</button>
</form>
<!-- Search Section -->
<div class="search-container">
<input type="text" id="searchInput" class="form-control"
placeholder="Search category by name...">
</div>
<h4 class="mb-3">All Categories</h4>
<table class="table table-bordered table-hover shadow-sm">
<thead class="table-dark">
<tr>
<th>Category ID</th>
<th>Category Name</th>
</tr>
</thead>
<tbody>
<tr>
<% for (Category c : categories) { %>
<td><%= [Link]() %></td>
<td><%= [Link]() %></td>
</tr>
<%
%>
</tbody>
</table>
</div>
<script>
// Search functionality
[Link]('searchInput').addEventListener('input', function() {
const searchTerm = [Link]();
const rows = [Link]('.table tbody tr');
[Link](row => {
const name = [Link][1].[Link]();
if ([Link](searchTerm)) {
[Link] = '';
} else {
[Link] = 'none';
});
});
</script>
</body>
</html>
[Link] >
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="[Link].*, [Link]" %>
<%
String myEmail = (String) [Link]("userEmail");
String myName = (String) [Link]("userName");
if (myEmail == null) { [Link]("[Link]"); return; }
final String ADMIN_EMAIL = "myahmuethwe5@[Link]";
String chatWith = [Link]("with");
if (chatWith == null || [Link]()) chatWith = ADMIN_EMAIL;
String otherName = "Admin";
if (!ADMIN_EMAIL.equals(chatWith)) {
try (Connection con = [Link]();
PreparedStatement ps = [Link]("SELECT name FROM user WHERE email_phone=?"))
{
[Link](1, chatWith);
try (ResultSet rs = [Link]()) { if ([Link]()) otherName = [Link](1); }
} catch (Exception ignored) {}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Messenger – <%= otherName %></title>
<link href="[Link] rel="stylesheet">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; font-family: "Poppins", sans-serif; }
body { background: #f5f6fa; display: flex; height: 100vh; }
/* Sidebar */
.sidebar {
width: 260px;
background: linear-gradient(180deg, #8e2de2, #4a00e0);
padding: 20px;
box-shadow: 4px 0 15px rgba(0,0,0,0.2);
display: flex;
flex-direction: column;
color: #fff;
border-radius: 0 20px 20px 0;
/* Profile */
.profile { text-align: center; margin-bottom: 30px; }
.profile h3 { margin-bottom: 8px; font-size: 18px; font-weight: 600; color: #fff; text-shadow: 1px 1px 3px
rgba(0,0,0,0.4); }
/* Photo Container */
.photo-container {
position: relative; display: inline-block;
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
border-radius: 50%;
.photo-container img {
width: 90px; height: 90px; border-radius: 50%;
border: 3px solid #fff; object-fit: cover;
transition: transform 0.3s, box-shadow 0.3s;
.photo-container img:hover { transform: scale(1.05); box-shadow: 0 6px 15px rgba(0,0,0,0.4); }
/* Upload Button */
.upload-btn {
position: absolute; bottom: 0; right: 0;
background: linear-gradient(to right, #ff5f6d, #ffc371);
color: white; width: 28px; height: 28px;
border-radius: 50%; text-align: center;
line-height: 28px; font-size: 20px; cursor: pointer;
box-shadow: 0 3px 6px rgba(0,0,0,0.3);
transition: transform 0.2s;
.upload-btn:hover { transform: scale(1.2); }
/* Logout Button */
.logout-btn {
padding: 10px 16px;
background: linear-gradient(to right, #ff416c, #ff4b2b);
color: #fff; border: none; border-radius: 12px;
cursor: pointer; font-size: 14px; font-weight: 600;
margin-top: auto; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
transition: transform 0.2s;
.logout-btn:hover { transform: scale(1.05); }
/* Menu */
.menu { margin-top: 20px; flex: 1; }
.menu a {
display: flex; align-items: center;
text-decoration: none;
color: #fff; padding: 12px;
border-radius: 12px;
margin-bottom: 12px;
font-size: 15px; font-weight: 500;
transition: 0.3s;
background: rgba(255,255,255,0.05);
box-shadow: 0 2px 6px rgba(0,0,0,0.15);
.menu a:hover {
background: rgba(255,255,255,0.2);
transform: translateX(5px);
}
.menu [Link] {
background: linear-gradient(90deg, #ff5f6d, #ffc371);
color: #fff;
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
.menu a i { margin-right: 12px; font-size: 18px; color: #fff; }
/* Main Content */
.main { flex: 1; padding: 30px; background: url("images/[Link]") no-repeat center
center/cover;background: #f5f6fa; border-radius: 20px 0 0 20px; box-shadow: inset 0 0 10px
rgba(0,0,0,0.05); }
body{background:#f0f2f5;}
.chat-wrap{max-width:900px;margin:24px auto;background:#fff;border-radius:16px;box-shadow:0 10px
30px rgba(0,0,0,.08);overflow:hidden;}
.header{display:flex;align-items:center;gap:12px;padding:14px 16px;background:linear-
gradient(45deg,#8e2de2,#4a00e0);color:#fff;}
.avatar{width:40px;height:40px;border-radius:50%;object-fit:cover;background:#ddd;}
.title{font-weight:600;}
.subtitle{font-size:12px;opacity:.9;}
.messages{height:520px;overflow:auto;padding:16px;background:#f7f8fc;}
.bubble-row {
display: flex;
align-items: flex-end;
margin: 8px 0;
gap: 8px;
.[Link]{justify-content:flex-end;}
.[Link]{justify-content:flex-start;}
.bubble {
max-width: 80%;
min-width: 60px;
padding: 12px 16px;
border-radius: 18px;
word-wrap: break-word;
white-space: pre-wrap;
line-height: 1.5;
font-size: 14px;
display: inline-block;
overflow-wrap: break-word;
.[Link]{background:#4a61ff;color:#fff;}
.[Link]{background:#f1f0f0;color:#000;}
.time{font-size:11px;color:#888;margin-top:4px;text-align:right;}
.inputbar{position:relative;display:flex;gap:8px;padding:10px;border-top:1px solid #eee;background:#fff;}
.inputbar input[type=text]{flex:1;border:1px solid #ddd;border-radius:24px;padding:10px 14px;}
.inputbar .btn{border-radius:20px;}
.typing{font-size:12px;color:#fff;opacity:.9;}
.emoji-btn{width:42px;border:1px solid #ddd;background:#fff;border-radius:20px;}
.emoji-panel{ display:none; position:absolute; bottom:60px; right:16px; background:#fff; border:1px solid
#e5e5e5; border-radius:12px; padding:8px; box-shadow:0 8px 24px rgba(0,0,0,.12); width:260px; max-
height:220px; overflow:auto; z-index:10;}
.[Link]{ display:block; }
.emoji-panel button{ font-size:20px; padding:6px; border:none; background:transparent; cursor:pointer;
border-radius:8px; }
.emoji-panel button:hover{ background:#f5f5f5; }
</style>
</head>
<body>
<div class="sidebar">
<div class="profile">
<div class="photo-container">
<img src="DisplayPhotoServlet" alt="User" id="profileImg">
<form action="UploadPhotoServlet" method="post" enctype="multipart/form-data"
id="uploadForm">
<label for="photoInput" class="upload-btn">+</label>
<input type="file" name="photo" id="photoInput" accept="image/*" style="display:none;"
onchange="[Link]('uploadForm').submit();">
</form>
</div>
<br><br>
<h3><%= myName %></h3>
</div>
<div class="menu">
<a href="#" ><i class="fa-solid fa-box"></i> My Orders</a>
<a href="#"><i class="fa-solid fa-ban"></i> My Cancellation</a>
<a href="#"><i class="fa-solid fa-star"></i> My Reviews</a>
<a href="[Link]"><i class="fa-solid fa-user"></i> Account Information</a>
<a href="#"><i class="fa-solid fa-palette"></i> Skin-Test Results</a>
<a href="[Link]" class="active"><i class="fa-solid fa-comments"></i> Chat</a>
</div>
<button class="logout-btn" onclick="[Link]='LogoutServlet'">Log Out</button>
</div>
<div class="main">
<div class="chat-wrap">
<div class="header">
<img class="avatar" src="photo?email=<%= chatWith %>" onerror="[Link]='photo?email=<%= myEmail
%>';"/>
<div>
<div class="title"><%= otherName %></div>
<div class="subtitle" id="typingText">online</div>
</div>
</div>
<div id="msgs" class="messages">
<%
try (Connection con = [Link]();
PreparedStatement ps = [Link](
"SELECT sender_email, message, timestamp FROM messages " +
"WHERE (sender_email=? AND receiver_email=?) OR (sender_email=? AND receiver_email=?) " +
"ORDER BY timestamp ASC")) {
[Link](1, myEmail);
[Link](2, chatWith);
[Link](3, chatWith);
[Link](4, myEmail);
try (ResultSet rs = [Link]()) {
while ([Link]()) {
String s = [Link](1);
String m = [Link](2);
String t = [Link](3);
%>
<div class="bubble-row <%= [Link](myEmail)?"me":"other" %>">
<% if(){ %>
<img class="avatar" src="photo?email=<%= s %>" onerror="[Link]='hidden'"/>
<% } %>
<div>
<div class="bubble <%= [Link](myEmail)?"me":"other" %>"><%= m %></div>
<div class="time"><%= t %></div>
</div>
</div>
<%
} catch(Exception e){ [Link]("<div class='text-danger p-3'>"+[Link]()+"</div>"); }
%>
</div>
<form class="inputbar" action="SendMessageServlet2" method="post" onsubmit="stopTypingSoon()">
<button type="button" id="emojiBtn" class="emoji-btn"> 😊</button>
<input type="hidden" name="receiver" value="<%= chatWith %>"/>
<input id="msgInput" type="text" name="message" placeholder="Write a message…" required/>
<button class="btn btn-primary" type="submit">Send</button>
<div id="emojiPanel" class="emoji-panel">
😀
<button> </button><button> 😁</button><button>😂</button><button>🤣</button><button>😊
</button>
😍
<button> </button><button> 😘</button><button>😎</button><button>🤩</button><button>🤔
</button>
👏
<button> </button><button> 👍</button><button>🙏</button><button>🔥</button>
💯
<button> </button>
🎉
<button> </button><button> 🥳</button><button>✅</button><button>❗</button>
✨
<button> </button>
</div>
</form>
</div>
</div>
<script>
function insertAtCursor(input,text){
const start=[Link],end=[Link],val=[Link];
[Link]=[Link](0,start)+text+[Link](end);
[Link](start+[Link],start+[Link]);
[Link]();
function setupEmojiPicker(btnId,panelId,inputId){
const
btn=[Link](btnId),panel=[Link](panelId),input=[Link]
mentById(inputId);
[Link]('click',()=>[Link]('show'));
[Link]('button').forEach(b=>{
[Link]('click',()=>{ insertAtCursor(input,[Link]); [Link]('show'); });
});
[Link]('click',(e)=>{ if(&&[Link]!==btn)
[Link]('show'); });
}
setupEmojiPicker('emojiBtn','emojiPanel','msgInput');
const myEmail="<%= myEmail %>";
const otherEmail="<%= chatWith %>";
const msgs=[Link]('msgs');
const typingText=[Link]('typingText');
const input=[Link]('msgInput');
function fetchHTML(url,cb){ const xhr=new XMLHttpRequest(); [Link]('GET',url,true); [Link]=
()=>cb([Link]); [Link](); }
function refreshMessages(){ fetchHTML('LoadMessagesServlet?with='+encodeURIComponent(otherEmail),
(html)=>{ [Link]=html; [Link]=[Link]; }); }
setInterval(refreshMessages,1500);
[Link]=refreshMessages;
let typingTimer=null,sentTyping=false;
function setTyping(on){ const fd=new FormData(); [Link]('isTyping',on?'1':'0'); [Link]?
[Link]('typing',fd):fetch('typing',{method:'POST',body:fd}); }
[Link]('input',()=>{
if(!sentTyping){ setTyping(true); sentTyping=true; }
if(typingTimer) clearTimeout(typingTimer);
typingTimer=setTimeout(()=>{ setTyping(false); sentTyping=false; },1200);
});
function stopTypingSoon(){ setTimeout(()=>{ setTyping(false); sentTyping=false; },100); }
function pollOtherTyping(){
fetch('typing?email='+encodeURIComponent(otherEmail)).then(r=>[Link]()).then(j=>{
[Link]=[Link]?(otherEmail==="<%= ADMIN_EMAIL %>"?"Admin is
typing…":"typing…"):"online";
}).catch(()=>{});
setInterval(pollOtherTyping,1200);
pollOtherTyping();
</script>
<script>
const links = [Link]('.menu a');
[Link](link => {
[Link]('click', () => {
[Link](l => [Link]('active'));
[Link]('active');
});
});
</script>
</body>
</html>
[Link] >
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Forgot Password</title>
<link href="[Link]
rel="stylesheet">
<style>
* { margin:0; padding:0; box-sizing: border-box; }
body {
font-family: 'Roboto', sans-serif;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-image:url("images/[Link]");
background-size:cover;
overflow: hidden;
position: relative;
/* Floating shapes */
.shape {
position: absolute;
border-radius: 50%;
opacity: 0.2;
background: green;
animation: float 7s ease-in-out infinite;
.shape1 { width: 100px; height: 100px; top: 10%; left: 10%; animation-duration: 6s; }
.shape2 { width: 150px; height: 150px; top: 60%; left: 80%; animation-duration: 8s; }
.shape3 { width: 80px; height: 80px; top: 35%; left: 50%; animation-duration: 7s; }
@keyframes float {
0% { transform: translateY(0) rotate(0deg); }
50% { transform: translateY(-25px) rotate(15deg); }
100% { transform: translateY(0) rotate(0deg); }
/* Glass card */
.container {
position: relative;
z-index: 1;
background: rgba(255, 255, 255, 0.3);
backdrop-filter: blur(12px);
padding: 50px 40px;
border-radius: 25px;
box-shadow: 0 20px 50px rgba(0,0,0,0.25);
width: 400px;
text-align: center;
animation: fadeIn 1s ease-out;
@keyframes fadeIn { from {opacity:0; transform: translateY(-20px);} to {opacity:1; transform:
translateY(0);} }
/* Lock icon */
.lock-icon {
width: 70px;
height: 70px;
margin: 0 auto 20px;
background: url('[Link] no-repeat center/contain;
animation: bounce 2s infinite;
@keyframes bounce { 0%,100%{transform:translateY(0);} 50%{transform:translateY(-10px);} }
h2 {
font-size: 32px;
font-weight: 700;
color: #ff4d6d;
margin-bottom: 15px;
.info-text {
font-size: 15px;
color: #555;
margin-bottom: 25px;
input {
width: 100%;
padding: 15px 18px;
margin-bottom: 20px;
border-radius: 12px;
border: 1px solid rgba(255,255,255,0.6);
font-size: 16px;
background: rgba(255,255,255,0.6);
backdrop-filter: blur(6px);
transition: all 0.3s ease;
input:focus {
border-color: #ff4d6d;
box-shadow: 0 0 8px rgba(255,77,109,0.4);
outline: none;
background: rgba(255,255,255,0.8);
.error-msg {
color: #ff4d6d;
font-size: 14px;
margin-bottom: 10px;
display: none;
button {
width: 100%;
padding: 15px;
font-size: 16px;
font-weight: 700;
color: white;
background: linear-gradient(90deg, #1F1C24, #1F1C24);
border: none;
border-radius: 12px;
cursor: pointer;
transition: all 0.3s ease;
}
button:hover {
background: linear-gradient(90deg, #0DA7E0, #0DA7E0);
box-shadow: 0 5px 15px rgba(255,77,109,0.4);
transform: scale(1.02);
@media (max-width: 480px) {
.container { width: 90%; padding: 35px 20px; }
</style>
</head>
<body>
<!-- Floating shapes -->
<div class="shape shape1"></div>
<div class="shape shape2"></div>
<div class="shape shape3"></div>
<div class="container">
<div class="lock-icon"></div>
<h2>Forgot Password</h2>
<p class="info-text">Enter your registered email to receive an OTP for password reset.</p>
<form id="forgotForm" action="ForgotpasswordSendOTPServlet" method="post">
<input type="email" id="email" name="email" placeholder="Enter your email" required>
<div class="error-msg" id="errorMsg">Please enter a valid email address!</div>
<button type="submit">Send OTP</button>
</form>
</div>
</body>
</html>
[Link] >
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Verify OTP</title>
<style>
/* Global reset */
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
body {
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-image:url("[Link]");
background-size:cover;
.otp-wrapper {
display: flex;
flex-direction: row;
width: 800px;
max-width: 95%;
background: #ffffff;
border-radius: 20px;
overflow: hidden;
box-shadow: 0 20px 40px rgba(0,0,0,0.15);
transition: transform 0.3s ease;
.otp-wrapper:hover {
transform: translateY(-5px);
.otp-left {
background: #fffaf0; /* soft cream */
color: #6b7280; /* muted gray for text */
padding: 40px;
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
.otp-left h2 {
font-size: 28px;
margin-bottom: 15px;
color: #111827;
.otp-left p {
font-size: 16px;
line-height: 1.5;
opacity: 0.9;
.otp-left img {
margin-top: 25px;
width: 120px;
height: auto;
opacity: 0.85;
.otp-right {
flex: 1;
padding: 50px 30px;
display: flex;
flex-direction: column;
justify-content: center;
background: #fff; /* soft mint/pastel green */
border-radius: 0 20px 20px 0;
color: #374151; /* dark gray text */
.otp-right h2 {
font-size: 26px;
margin-bottom: 10px;
text-align: center;
.otp-right [Link] {
font-size: 14px;
text-align: center;
margin-bottom: 25px;
color: #4b5563; /* slightly lighter gray */
}
.otp-input {
display: flex;
justify-content: space-between;
margin-bottom: 30px;
.otp-input input {
width: 50px;
height: 50px;
text-align: center;
font-size: 22px;
border-radius: 10px;
border: 1px solid #cbd5e1;
transition: all 0.3s ease;
.otp-input input:focus {
border-color: #f9a8d4; /* soft rose accent */
box-shadow: 0 0 5px rgba(249,168,212,0.5);
outline: none;
button {
width: 100%;
padding: 15px;
background: linear-gradient(90deg, #293136, #1C272E); /* rose gradient */
color: #fff;
border: none;
border-radius: 12px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
button:hover {
background: linear-gradient(90deg, #0DA7E0, #0DA7E0);
transform: translateY(-2px);
@media(max-width: 768px) {
.otp-wrapper {
flex-direction: column;
.otp-left, .otp-right {
padding: 30px;
.otp-left img {
width: 80px;
.otp-input input {
width: 40px;
height: 45px;
font-size: 20px;
</style>
</head>
<body>
<div class="otp-wrapper">
<div class="otp-left">
<h2>Secure Verification</h2>
<p>For your account safety, please verify the OTP sent to your email or phone number.</p>
<img src="[Link] alt="OTP Icon">
</div>
<div class="otp-right">
<h2>Enter OTP</h2>
<p class="instruction">Enter the 6-digit code below:</p>
<form action="ForgotpasswordVerifyOTPServlet" method="post">
<div class="otp-input">
<input type="text" name="otp" maxlength="1" pattern="\d" required>
<input type="text" name="otp" maxlength="1" pattern="\d" required>
<input type="text" name="otp" maxlength="1" pattern="\d" required>
<input type="text" name="otp" maxlength="1" pattern="\d" required>
<input type="text" name="otp" maxlength="1" pattern="\d" required>
<input type="text" name="otp" maxlength="1" pattern="\d" required>
</div>
<button type="submit">Verify OTP</button>
</form>
</div>
</div>
<script>
// Auto focus to next input
const inputs = [Link]('.otp-input input');
[Link]((input, index) => {
[Link]('input', () => {
if([Link] === 1 && index < [Link] - 1){
inputs[index + 1].focus();
});
[Link]('keydown', (e) => {
if([Link] === "Backspace" && ![Link] && index > 0){
inputs[index - 1].focus();
});
});
</script>
</body>
</html>
haarcascade_frontalface_alt.xml >
[Link]> [Link]>
[Link] > [Link] > [Link] > [Link] > [Link] >
[Link] > [Link] >[Link] > [Link]