diff --git a/.gitignore b/.gitignore
index 01f91ee8afd8089164614770818bf8c749e40ca9..d1e6d10a2e90e9e5ebf063bf8ddbf25a2a2e6ed8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,4 +23,4 @@
 
 #config file
 *.xml
-*.properties
\ No newline at end of file
+*.properties
diff --git a/ChatService/src/java/org/ChatService/RetrieveStatus.java b/ChatService/src/java/org/ChatService/RetrieveStatus.java
new file mode 100644
index 0000000000000000000000000000000000000000..f00526ba59cb0cc1da4249e1e6c90e4f34f527ab
--- /dev/null
+++ b/ChatService/src/java/org/ChatService/RetrieveStatus.java
@@ -0,0 +1,120 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.ChatService;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.json.simple.JSONObject;
+
+/**
+ *
+ * @author Azka Hanif Imtiyaz
+ */
+@WebServlet(name = "RetrieveStatus", urlPatterns = {"/RetrieveStatus"})
+public class RetrieveStatus extends HttpServlet {
+
+    /**
+     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
+     * methods.
+     *
+     * @param request servlet request
+     * @param response servlet response
+     * @throws ServletException if a servlet-specific error occurs
+     * @throws IOException if an I/O error occurs
+     */
+    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+         response.setContentType("application/json");
+        response.setCharacterEncoding("utf-8");
+        JSONObject json = new JSONObject();
+        try {
+            Connection conn = DBChatToken.getConnection();
+            if (conn != null) {
+                Statement stmt = conn.createStatement();
+                String sql;
+                String username = request.getParameter("username");
+                sql = "SELECT * FROM chattoken WHERE username =\"" + username+"\"";
+                ResultSet rs = stmt.executeQuery(sql);
+                
+                if (rs.next()){
+                    json.put("status", "ON");
+                } else {
+                    json.put("status", "OFF");
+                }
+
+                PrintWriter out = response.getWriter();
+                
+                out.print(json.toString());
+            } else {
+                try (PrintWriter out = response.getWriter()) {
+                    /* TODO output your page here. You may use following sample code. */
+                    out.println("<!DOCTYPE html>");
+                    out.println("<html>");
+                    out.println("<head>");
+                    out.println("<title>Servlet login</title>");
+                    out.println("</head>");
+                    out.println("<body>");
+                    out.println("<h1>Connection NULL!!</h1>");
+                    out.println("</body>");
+                    out.println("</html>");
+                }
+            }
+        } catch (SQLException ex) {
+            Logger.getLogger(TokenSaver.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
+    /**
+     * Handles the HTTP <code>GET</code> method.
+     *
+     * @param request servlet request
+     * @param response servlet response
+     * @throws ServletException if a servlet-specific error occurs
+     * @throws IOException if an I/O error occurs
+     */
+    @Override
+    protected void doGet(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        processRequest(request, response);
+    }
+
+    /**
+     * Handles the HTTP <code>POST</code> method.
+     *
+     * @param request servlet request
+     * @param response servlet response
+     * @throws ServletException if a servlet-specific error occurs
+     * @throws IOException if an I/O error occurs
+     */
+    @Override
+    protected void doPost(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        processRequest(request, response);
+    }
+
+    /**
+     * Returns a short description of the servlet.
+     *
+     * @return a String containing servlet description
+     */
+    @Override
+    public String getServletInfo() {
+        return "Short description";
+    }// </editor-fold>
+
+}
diff --git a/ChatService/src/java/org/ChatService/SendMessage.java b/ChatService/src/java/org/ChatService/SendMessage.java
index e146d1537b9d593d1aa8cae392fe1ba78f8d74e2..1a6fa1444160366b47245b598a2bd70f0a032a96 100644
--- a/ChatService/src/java/org/ChatService/SendMessage.java
+++ b/ChatService/src/java/org/ChatService/SendMessage.java
@@ -56,7 +56,7 @@ public class SendMessage extends HttpServlet {
                 if(rs.next()){
                     JSONObject json = new JSONObject();
                     JSONObject json1 = new JSONObject();
-                    String chattoken =rs.getString("chattoken");
+                    String chattoken = rs.getString("chattoken");
                     /* Format json
                     {data : {
                         username : xx
diff --git a/ChatService/src/java/org/ChatService/TokenSaver.java b/ChatService/src/java/org/ChatService/TokenSaver.java
index d2180c784488b1f5477531b9dfbb2014f39e79e3..5b9c49ad14637ce6e79f4f7bd19957121679aa3b 100644
--- a/ChatService/src/java/org/ChatService/TokenSaver.java
+++ b/ChatService/src/java/org/ChatService/TokenSaver.java
@@ -5,8 +5,6 @@ package org.ChatService;
  * To change this template file, choose Tools | Templates
  * and open the template in the editor.
  */
-
-import org.ChatService.DBChatToken;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.sql.Connection;
@@ -21,7 +19,6 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import org.json.simple.JSONObject;
 
-
 /**
  *
  * @author khrs
@@ -46,21 +43,25 @@ public class TokenSaver extends HttpServlet {
         JSONObject json = new JSONObject();
         try {
             Connection conn = DBChatToken.getConnection();
-            if (conn != null){
+            if (conn != null) {
                 Statement stmt = conn.createStatement();
                 String sql;
                 String username = request.getParameter("username");
                 String chattoken = request.getParameter("chattoken");
-                sql = "insert into chattoken values (\""+ chattoken+ "\",\""+username+"\")";
+                sql = "insert into chattoken values (\"" + chattoken + "\",\"" + username + "\")";
                 stmt.executeUpdate(sql);
-            }
-            else{
+
+                PrintWriter out = response.getWriter();
+                
+                json.put("status", "ON");
+                out.print(json.toString());
+            } else {
                 try (PrintWriter out = response.getWriter()) {
                     /* TODO output your page here. You may use following sample code. */
-                       out.println("<!DOCTYPE html>");
+                    out.println("<!DOCTYPE html>");
                     out.println("<html>");
                     out.println("<head>");
-                    out.println("<title>Servlet login</title>");            
+                    out.println("<title>Servlet login</title>");
                     out.println("</head>");
                     out.println("<body>");
                     out.println("<h1>Connection NULL!!</h1>");
@@ -85,7 +86,6 @@ public class TokenSaver extends HttpServlet {
             out.println("</body>");
             out.println("</html>");
         }*/
-        
     }
 
     // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
diff --git a/IdentService/build/web/WEB-INF/classes/org/IdentService/login.class b/IdentService/build/web/WEB-INF/classes/org/IdentService/login.class
index 31a29c2b45db8fb6cd6627bb6dc3d8408455a93b..5371d1e459b9d919c2df7acf3a6c141b1e234a15 100644
Binary files a/IdentService/build/web/WEB-INF/classes/org/IdentService/login.class and b/IdentService/build/web/WEB-INF/classes/org/IdentService/login.class differ
diff --git a/IdentService/dist/IdentService.war b/IdentService/dist/IdentService.war
index 092e9ac23cf38a8b9cf94ee2a5f00ddea3724c7e..f5d7b89c728857ac402b55f28ee602dcc7d0220a 100644
Binary files a/IdentService/dist/IdentService.war and b/IdentService/dist/IdentService.war differ
diff --git a/IdentService/nbproject/private/private.xml b/IdentService/nbproject/private/private.xml
index 24ff876f8e6eae4074d618b23c8fcf61a00bee12..b8898546544f7ee030744cd458347e22d3715d7c 100644
--- a/IdentService/nbproject/private/private.xml
+++ b/IdentService/nbproject/private/private.xml
@@ -3,11 +3,11 @@
     <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
         <group>
+            <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/IdentService/src/java/org/IdentService/validate.java</file>
             <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/IdentService/src/java/org/IdentService/logout.java</file>
+            <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/IdentService/src/java/org/IdentService/DBAccount.java</file>
             <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/IdentService/src/java/org/IdentService/RetrieveAccount.java</file>
             <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/IdentService/src/java/org/IdentService/register.java</file>
-            <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/IdentService/src/java/org/IdentService/DBAccount.java</file>
-            <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/IdentService/src/java/org/IdentService/validate.java</file>
         </group>
     </open-files>
 </project-private>
diff --git a/IdentService/src/java/org/IdentService/login.java b/IdentService/src/java/org/IdentService/login.java
index f8def43345eb4ea75fcf23afd6c33a49b5146205..96d4bc90b81e31cbc883608bbe5e9a03a9b1e175 100644
--- a/IdentService/src/java/org/IdentService/login.java
+++ b/IdentService/src/java/org/IdentService/login.java
@@ -83,6 +83,7 @@ public class login extends HttpServlet {
                 ResultSet rs = stmt.executeQuery(sql);
                 if (rs.next()){
                    int user_id = rs.getInt("user_id");
+                   String user = rs.getString("username");
                    //String generatedToken = generateToken(request);
                    Calendar cal = Calendar.getInstance();
                    int hours = cal.get(Calendar.HOUR_OF_DAY);
@@ -107,10 +108,11 @@ public class login extends HttpServlet {
                    json.put("status","OK");
                    json.put("token",generatedToken);
                    json.put("user_id",user_id);
+                   json.put("username",user);
                    out.print(json.toString());
                 }
                 else{
-                    PrintWriter out = response.getWriter();
+                    PrintWriter out = response.getWriter(); 
                     json.put("status","FAILED");
                     out.print(json.toString());
                 }
diff --git a/KAA-JSP/build/web/catalog.jsp b/KAA-JSP/build/web/catalog.jsp
index 604e7be95fa2012001bad979e21691896d3bd703..0bba014676d93a65556830aada0cf368b2dd5f21 100644
--- a/KAA-JSP/build/web/catalog.jsp
+++ b/KAA-JSP/build/web/catalog.jsp
@@ -22,11 +22,11 @@
 <html>
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-	<title>Sale Project - Catalog</title>
-	<link href="css/style.css" rel="stylesheet" type="text/css">
+        <title>Sale Project - Catalog</title>
+        <link href="css/style.css" rel="stylesheet" type="text/css">
         <!-- Firebase -->
         <script src="https://www.gstatic.com/firebasejs/3.6.1/firebase.js"></script>
-         <!--Angular -->
+        <!--Angular -->
         <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
         <!--<script src="https://cdn.firebase.com/js/client/2.0.4/firebase.js"></script>--> 
         <!--<script src="https://www.gstatic.com/firebasejs/3.6.1/firebase-app.js"></script>
@@ -35,390 +35,316 @@
         <script src="https://www.gstatic.com/firebasejs/3.6.1/firebase-messaging.js"></script>
         <!-- <script src="https://www.gstatic.com/firebasejs/3.6.1/firebase-storage.js"></script> -->
         <!-- AngularFire -->
-<!--        <script src="https://cdn.firebase.com/libs/angularfire/0.9.2/angularfire.min.js"></script>-->
- 
-        <script>
-          // Initialize Firebase
+        <!--        <script src="https://cdn.firebase.com/libs/angularfire/0.9.2/angularfire.min.js"></script>-->
 
-          /*var config = {
-            apiKey: "AIzaSyAN43gCcqFx095nCBy-4abeRGkoZB1-Rok",
-            authDomain: "kaa-saleproject.firebaseapp.com",
-            databaseURL: "https://kaa-saleproject.firebaseio.com",
-            storageBucket: "kaa-saleproject.appspot.com",
-            messagingSenderId: "815161898662"
-          };*/
-/*        var config = {
-          apiKey: "AIzaSyAQ2WIB6GWOxmtwMdGd8eHawL4PWxK8evU",
-          authDomain: "tugas-besar-wbd.firebaseapp.com",
-          databaseURL: "https://tugas-besar-wbd.firebaseio.com",
-          storageBucket: "tugas-besar-wbd.appspot.com",
-          messagingSenderId: "1049009619420"
-        };
-          firebase.initializeApp(config);
-          
-          const messaging = firebase.messaging();
-          messaging.requestPermission()
-            .then(function() {
-              console.log('Notification permission granted.');
-              return messaging.getToken();
-              // TODO(developer): Retrieve an Instance ID token for use with FCM.
-              // ...
-            })
-            .then(function(token){
-                console.log(token); 
-            })
-            .catch(function(err) {
-              console.log('Unable to get permission to notify.', err);
-            });*/
-    
-    
-          /*messaging.requestPermission().then(function(){
-              console.log('Notification permission granted');
-              messaging.getToken().then(function(){
-                  if(currentToken){
-                      sendTokenToServer(currentToken);
-                      updateUIForPushEnabled(currentToken);
-                      console.log('Token retrieved, ',currentToken);
-                      //abis itu send ke tokensaver chatservice di sini atau di bawah
-                  } else {
-                      console.log('No Instance ID token available. Request permission to generate one');
-                      updateUIForPushPermissionRequired();
-                      setTokenToServer(false);
-                  }
-              }).catch(function(err){
-                  console.log('An error occured while retrieving token. ',err);
-                  showToken('Error retrieving Instance ID token. ',err);
-                  setTokenToServer(false);
-              });
-          }).catch(function(err){
-              console.log('Unable to get permission to notify',err);
-          });
-          
-          messaging.onTokenRefresh(function(){
-              mesagging.getToken().then(function(refreshedToken){
-                  console.log('Token refreshed.');
-                  setTokenSentToServer(false);
-                  sendTokenToServer(refreshedToken);
-              });
-          }).catch(function(err){
-              console.log('Unable to retrieve refreshed token. ',err);
-              showToken('Unable to retrieve refreshed token. ',err);
-          });
-          
-          messaging.onMessage(function(payload){
-              console.log("Message received. ",payload);
-          });*/
 
-        </script>
         <!--Application -->
         <script src="scripts/app.js"></script>
 
-        
+
     </head>
     <body ng-app="chatApp" ng-controller="chatController">
-	<div class="catalog_content">
-        <div class="logo">
-            <span id="red">Sale</span><span id="blue">Project</span>
-        </div>
-        <div class="information">
-       <span>
-        <%
-/*            FirebaseOptions options = new FirebaseOptions.Builder()
-            .setServiceAccount(new FileInputStream("path/to/serviceAccountKey.json"))
-            .setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/")
-            .build();
+        <div class="catalog_content">
+            <div class="logo">
+                <span id="red">Sale</span><span id="blue">Project</span>
+            </div>
+            <div class="information">
+                <span>
+                    <%
+                        /*            FirebaseOptions options = new FirebaseOptions.Builder()
+                        .setServiceAccount(new FileInputStream("path/to/serviceAccountKey.json"))
+                        .setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/")
+                        .build();
 
-            FirebaseApp.initializeApp(options);*/
-            
-            JSONObject responseJSON = new JSONObject();
-            JSONObject responseJSON1 = new JSONObject();
-            org.kaa.marketplaceservice.service.MarketPlaceService_Service service = new org.kaa.marketplaceservice.service.MarketPlaceService_Service();
-            org.kaa.marketplaceservice.service.MarketPlaceService port = service.getMarketPlaceServicePort();        
-            String query;
-            String APIURL;
-            String ParameterURL;
-            
-            /* Showing username of user */
-            String user_token = request.getParameter("token");
-            if (request.getParameter("like") != null){
-               String productId = request.getParameter("product_id");
-               boolean like;
-               if (request.getParameter("like").equals("yes")){
-                   like = true;
-               } else {
-                   like = false;
-               }
-               ProcedureStatus result = port.processLike(user_token, productId, like);
-               if (result.getStatus().equals("OK")){
-                   //Do nothing
-                } else if (result.getStatus().equals("EXPIRED")) {
-                    response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
-                                         + "message=Expired");
-                } else {
-                    response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
-                            + "jsp?token="+user_token+"&message=error");
-                }
-            }
-            
-            if ((request.getParameter("logout") == null) && 
-                    (request.getParameter("token")!= null)){
-                /* Consume REST API */
-                ParameterURL = "token="+ request.getParameter("token");
-                APIURL = "http://localhost:8080/IdentService/validate?";
-                RestAPI_consumer consumer = new RestAPI_consumer(APIURL,ParameterURL);
-                consumer.execute();
-                responseJSON = consumer.getOutput();
-                
-                /* Checking the response */
-                String status = (String)responseJSON.get("status");
-                if (status.equals("OK")){
-                        String user = (String)responseJSON.get("user_name");
-                        out.println("Hello, " + user);
-                        //out.println("<script>setUser('"+user+"');</script>");
-                }
-                else{
-                        response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
-                                        + "jsp?token="+user_token);
-                }
-            }
-            /* Logout */
-            else if ((request.getParameter("logout") != null) && 
-                    (request.getParameter("token")!= null)){
-                URL obj1 = null;
-                try{
-                    /* Consume REST API */
-                    ParameterURL = "token="+ user_token;
-                    APIURL = "http://localhost:8080/IdentService/logout?";
-                    RestAPI_consumer consumer1 = new RestAPI_consumer(APIURL,ParameterURL);
-                    consumer1.execute();
-                    responseJSON1 = consumer1.getOutput();
-                    
-                    /* Checking the response */
-                    String status1 = (String)responseJSON1.get("status");
-                    if (status1.equals("OK")){
-                        response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
-                                + "message=logout");
-                    }
-                    else{
-                        response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
-                                + "jsp?token="+user_token);
-                    }
-                }
-                catch(Exception e){
-                    e.printStackTrace();
-                }
-            }
+                        FirebaseApp.initializeApp(options);*/
 
-            /*          Firebase here  
-            String uid = "some-uid";
+                        JSONObject responseJSON = new JSONObject();
+                        JSONObject responseJSON1 = new JSONObject();
+                        org.kaa.marketplaceservice.service.MarketPlaceService_Service service = new org.kaa.marketplaceservice.service.MarketPlaceService_Service();
+                        org.kaa.marketplaceservice.service.MarketPlaceService port = service.getMarketPlaceServicePort();
+                        String query;
+                        String APIURL;
+                        String ParameterURL;
 
-            FirebaseAuth.getInstance().createCustomToken(uid)
-                .addOnSuccessListener(new OnSuccessListener<String>() {
-                    @Override
-                    public void onSuccess(String customToken) {
-                        // Send token back to client
-                    }
-                });*/
-        %>
-        </span>
+                        String urlParamChat;
+                        String urlRequest2 = "http://localhost:8080/ChatService/RetrieveStatus?";
 
-        </br>
-            <a href="
-            <%
-                String logoutURL = "http://localhost:8080/KAA-JSP/catalog.jsp?token="+user_token+"&logout=on";
-                out.println(logoutURL);
-            %>
-               " class="logout"><span class="link">Logout</span>
-            </a><br/>
-        </div>
-        <table class="menu">
-            <th class="menupart" id="active">
-                <a href="
-                   <%
-                    out.println("http://localhost:8080/KAA-JSP/catalog.jsp?token="+user_token);
-                   %>
-                   ">
-                    Catalog
-                </a>
-            </th>
-            <th class="menupart">
-                <a href="
-                   <%
-                    out.println("http://localhost:8080/KAA-JSP/yourproduct.jsp?token="+user_token);
-                   %>
-                   ">
-                    Your Products
-                </a>
-            </th>
-            <th class="menupart">
-                <a href="
-                   <%
-                    out.println("http://localhost:8080/KAA-JSP/addproduct.jsp?token="+user_token);
-                   %>
-                   ">
-                    Add Product
-                </a>
-            </th>
-            <th class="menupart">
-                <a href="
-                   <%
-                    out.println("http://localhost:8080/KAA-JSP/sales.jsp?token="+user_token);
-                   %>
-                   ">
-                    Sales
-                </a>
-            </th>
-            <th class="menupart">
+                        /* Showing username of user */
+                        String user_token = request.getParameter("token");
+                        if (request.getParameter("like") != null) {
+                            String productId = request.getParameter("product_id");
+                            boolean like;
+                            if (request.getParameter("like").equals("yes")) {
+                                like = true;
+                            } else {
+                                like = false;
+                            }
+                            ProcedureStatus result = port.processLike(user_token, productId, like);
+                            if (result.getStatus().equals("OK")) {
+                                //Do nothing
+                            } else if (result.getStatus().equals("EXPIRED")) {
+                                response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
+                                        + "message=Expired");
+                            } else {
+                                response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
+                                        + "jsp?token=" + user_token + "&message=error");
+                            }
+                        }
+
+                        if ((request.getParameter("logout") == null)
+                                && (request.getParameter("token") != null)) {
+                            /* Consume REST API */
+                            ParameterURL = "token=" + request.getParameter("token");
+                            APIURL = "http://localhost:8080/IdentService/validate?";
+                            RestAPI_consumer consumer = new RestAPI_consumer(APIURL, ParameterURL);
+                            consumer.execute();
+                            responseJSON = consumer.getOutput();
+
+                            /* Checking the response */
+                            String status = (String) responseJSON.get("status");
+                            if (status.equals("OK")) {
+                                String user = (String) responseJSON.get("user_name");
+                                out.println("Hello, " + user);
+                                //out.println("<script>setUser('"+user+"');</script>");
+                            } else {
+                                response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
+                                        + "jsp?token=" + user_token);
+                            }
+                        } /* Logout */ else if ((request.getParameter("logout") != null)
+                                && (request.getParameter("token") != null)) {
+                            URL obj1 = null;
+                            try {
+                                /* Consume REST API */
+                                ParameterURL = "token=" + user_token;
+                                APIURL = "http://localhost:8080/IdentService/logout?";
+                                RestAPI_consumer consumer1 = new RestAPI_consumer(APIURL, ParameterURL);
+                                consumer1.execute();
+                                responseJSON1 = consumer1.getOutput();
+
+                                /* Checking the response */
+                                String status1 = (String) responseJSON1.get("status");
+                                if (status1.equals("OK")) {
+                                    response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
+                                            + "message=logout");
+                                } else {
+                                    response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
+                                            + "jsp?token=" + user_token);
+                                }
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        }
+
+
+                    %>
+                </span>
+
+                </br>
                 <a href="
-                   <%
-                    out.println("http://localhost:8080/KAA-JSP/purchases.jsp?token="+user_token);
+                   <%                String logoutURL = "http://localhost:8080/KAA-JSP/catalog.jsp?token=" + user_token + "&logout=on";
+                       out.println(logoutURL);
                    %>
-                   ">Purchases
-                </a>
-            </th>
-        </table>
-        <br/>
-        <p class="title">What are you going to buy today?</p>
-        <hr/>
-        <br/>
-        <div class="add_product_content">
+                   " class="logout"><span class="link">Logout</span>
+                </a><br/>
+            </div>
+            <table class="menu">
+                <th class="menupart" id="active">
+                    <a href="
+                       <%
+                           out.println("http://localhost:8080/KAA-JSP/catalog.jsp?token=" + user_token);
+                       %>
+                       ">
+                        Catalog
+                    </a>
+                </th>
+                <th class="menupart">
+                    <a href="
+                       <%
+                           out.println("http://localhost:8080/KAA-JSP/yourproduct.jsp?token=" + user_token);
+                       %>
+                       ">
+                        Your Products
+                    </a>
+                </th>
+                <th class="menupart">
+                    <a href="
+                       <%
+                           out.println("http://localhost:8080/KAA-JSP/addproduct.jsp?token=" + user_token);
+                       %>
+                       ">
+                        Add Product
+                    </a>
+                </th>
+                <th class="menupart">
+                    <a href="
+                       <%
+                           out.println("http://localhost:8080/KAA-JSP/sales.jsp?token=" + user_token);
+                       %>
+                       ">
+                        Sales
+                    </a>
+                </th>
+                <th class="menupart">
+                    <a href="
+                       <%
+                           out.println("http://localhost:8080/KAA-JSP/purchases.jsp?token=" + user_token);
+                       %>
+                       ">Purchases
+                    </a>
+                </th>
+            </table>
+            <br/>
+            <p class="title">What are you going to buy today?</p>
+            <hr/>
+            <br/>
+            <div class="add_product_content">
                 <form method="GET" enctype="multipart/form-data">
-                        <div class="input_catalog">
-                                <input type="hidden" name="token" value=<%
-                                    out.println(user_token);
-                                %> >
-                                <input type="text" placeholder="Search catalog ..." 
-                                    name="search" style="width:90%; height: 35px; border:none;" 
-                                    class="auto-style1" hidefocus="hidefocus">
-                                <input type="submit" value="GO" style="width: 10%; height: 35px; font-weight: bold"><br/>
-                                by
-                                <input class="radio" type="radio" name="choice" value="product" checked="checked" />
-                                <label><span>product</span></label><br />
-                                <input class="radio" type="radio" name="choice" value="store" style="margin-left:25px;" />
-                                <label><span>store</span></label>
-                        </div>
+                    <div class="input_catalog">
+                        <input type="hidden" name="token" value=<%
+                            out.println(user_token);
+                               %> >
+                        <input type="text" placeholder="Search catalog ..." 
+                               name="search" style="width:90%; height: 35px; border:none;" 
+                               class="auto-style1" hidefocus="hidefocus">
+                        <input type="submit" value="GO" style="width: 10%; height: 35px; font-weight: bold"><br/>
+                        by
+                        <input class="radio" type="radio" name="choice" value="product" checked="checked" />
+                        <label><span>product</span></label><br />
+                        <input class="radio" type="radio" name="choice" value="store" style="margin-left:25px;" />
+                        <label><span>store</span></label>
+                    </div>
                 </form>
-        </div>    
-        <%
-            if(request.getParameter("search") == null){
-                // Ketika pertama kali membuka catalog (tidak ada parameter search) 
-                List<Product> result = port.retrieveAllProduct(user_token);
-                
-                // Ketika token sudah expired
-                if (result == null){
-                        response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
-                                + "message=expired");
-                } else {
-                    if (result.size() == 0){
-                            out.print("<p>No product to be sold.</p>");
-                    } else {
-                        for (int i = 0; i < result.size(); i++) {
-                            out.print("<a href=\"\"><div ng-click=\"setReceiver('"+result.get(i).getUsername()+"')\"><p><b>" + result.get(i).getUsername() + "</a></b><br/>");
-                            out.print("added this on " + result.get(i).getDate().getDate() + "</p></div>");
-                            out.print("<hr/>");
-                            out.print("<table>");
-                            out.print("<tr class = \"container\">");
-                            out.print("<td>");
-                            out.print("<img \" width=120px height=120px src=\"" + result.get(i).getImage() + "\">");                                                       
-                            out.print("</td>");                                                     
-                            out.print("<td class=\"product_description\">");                                                             
-                            out.print("<p class=\"catalog_title\">" + result.get(i).getName() + " <br/></p>");                                                               
-                            out.print("<p class=\"catalog_price\">IDR " + result.get(i).getPrice() + "<br/></p>");                                                               
-                            out.print("<p class=\"catalog_desc\">" + result.get(i).getDescription() + "</p>");                                                        
-                            out.print("</td>");                                                        
-                            out.print("<td class=\"product_misc\">");                                                               
-                            out.print("<br/>");                                                               
-                            out.print("<p>" + port.getLikes(result.get(i).getProductId()) + " likes </p><br/>");                                                                     
-                            out.print("<p>" + port.getPurchases(result.get(i).getProductId()) + " purchases <br/>");  
-                            out.print(port.isLiked(user_token, result.get(i).getProductId()));                                                                        
-                            out.print("<a href=\"http://localhost:8080/KAA-JSP/confirmation_purchase.jsp?token=" + user_token + "&product_id=" + result.get(i).getProductId() + "\"><p id=\"buy\">BUY</a></p>");                                                                
-                            out.print("</td>");                                                       
-                            out.print("</tr>");                                                
-                            out.print("</table>");                                                
-                            out.print("<hr/>");                                               
-                            out.print("<br/>");                                              
-                            out.print("<br/>");
-                        }
-                    }
-                }
-           } else {
-                // Ketika ada parameter untuk search
-                String search = request.getParameter("search");
-                String choice = request.getParameter("choice");
-                /* Melakukan Searching dengan Method search_product pada MarketService */
-                try{
-                    int choice_int = 0;
-                    if (choice.equals("product")){
-                        choice_int = 0;
-                    } else if (choice.equals("store")) {
-                        choice_int = 1;
-                    }
-                    
-                    List<Product> result = port.searchProduct(search, user_token, choice_int);
-                    
-                    /* Jika expired */
-                    if (result == null){
+            </div>    
+            <%
+                if (request.getParameter("search") == null) {
+                    // Ketika pertama kali membuka catalog (tidak ada parameter search) 
+                    List<Product> result = port.retrieveAllProduct(user_token);
+
+                    // Ketika token sudah expired
+                    if (result == null) {
                         response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
                                 + "message=expired");
                     } else {
-                        if (result.size() == 0){
-                            out.print("<p>Nothing matches your search.</p>");
+                        if (result.size() == 0) {
+                            out.print("<p>No product to be sold.</p>");
                         } else {
                             for (int i = 0; i < result.size(); i++) {
-                                out.print("<a href=\"\"><div ng-click=\"setReceiver('"+result.get(i).getUsername()+"')\"><b>" + result.get(i).getUsername() + "</a></b></div><br/>");
+                                urlParamChat = "username=" + result.get(i).getUsername();
+                                RestAPI_consumer consumer2 = new RestAPI_consumer(urlRequest2, urlParamChat);
+                                consumer2.execute();
+                                responseJSON = consumer2.getOutput();
+                                if (responseJSON.get("status").equals("ON")) {
+                                    out.print("<img style=\"border: none; padding: 0px 10px 0px 0px; float:left\" height=15px width=15px src=\"img/on.png\">");
+                                    out.print("<a href=\"\"><div ng-click=\"setReceiver('" + result.get(i).getUsername() + "')\"><p><b>" + result.get(i).getUsername() + "</a></b><br/>");
+                                } else {
+                                    out.print("<img style=\"border: none; padding: 0px 10px 0px 0px; float:left\" height=15px width=15px src=\"img/off.png\">");
+                                    out.print("<a href=\"\"><div ng-click=\"setReceiver('" + result.get(i).getUsername() + "')\"><p><b>" + result.get(i).getUsername() + "</a></b><br/>");
+                                }
                                 out.print("added this on " + result.get(i).getDate().getDate() + "</p></div>");
                                 out.print("<hr/>");
                                 out.print("<table>");
                                 out.print("<tr class = \"container\">");
                                 out.print("<td>");
-                                out.print("<img \" width=120px height=120px src=\"" + result.get(i).getImage() + "\">");                                                       
-                                out.print("</td>");                                                     
-                                out.print("<td class=\"product_description\">");                                                             
-                                out.print("<p class=\"catalog_title\">" + result.get(i).getName() + " <br/></p>");                                                               
-                                out.print("<p class=\"catalog_price\">IDR " + result.get(i).getPrice() + "<br/></p>");                                                               
-                                out.print("<p class=\"catalog_desc\">" + result.get(i).getDescription() + "</p>");                                                        
-                                out.print("</td>");                                                        
-                                out.print("<td class=\"product_misc\">");                                                               
-                                out.print("<br/>");                                                               
-                                out.print("<p>" + port.getLikes(result.get(i).getProductId()) + " likes </p><br/>");                                                                     
-                                out.print("<p>" + port.getPurchases(result.get(i).getProductId()) + " purchases <br/>");  
-                                out.print(port.isLiked(user_token, result.get(i).getProductId()));                                                                        
-                                out.print("<a href=\"http://localhost:8080/KAA-JSP/confirmation_purchase.jsp?token=" + user_token + "&product_id=" + result.get(i).getProductId() + "\"><p id=\"buy\">BUY</a></p>");                                                                
-                                out.print("</td>");                                                       
-                                out.print("</tr>");                                                
-                                out.print("</table>");                                                
-                                out.print("<hr/>");                                               
-                                out.print("<br/>");                                              
+                                out.print("<img \" width=120px height=120px src=\"" + result.get(i).getImage() + "\">");
+                                out.print("</td>");
+                                out.print("<td class=\"product_description\">");
+                                out.print("<p class=\"catalog_title\">" + result.get(i).getName() + " <br/></p>");
+                                out.print("<p class=\"catalog_price\">IDR " + result.get(i).getPrice() + "<br/></p>");
+                                out.print("<p class=\"catalog_desc\">" + result.get(i).getDescription() + "</p>");
+                                out.print("</td>");
+                                out.print("<td class=\"product_misc\">");
+                                out.print("<br/>");
+                                out.print("<p>" + port.getLikes(result.get(i).getProductId()) + " likes </p><br/>");
+                                out.print("<p>" + port.getPurchases(result.get(i).getProductId()) + " purchases <br/>");
+                                out.print(port.isLiked(user_token, result.get(i).getProductId()));
+                                out.print("<a href=\"http://localhost:8080/KAA-JSP/confirmation_purchase.jsp?token=" + user_token + "&product_id=" + result.get(i).getProductId() + "\"><p id=\"buy\">BUY</a></p>");
+                                out.print("</td>");
+                                out.print("</tr>");
+                                out.print("</table>");
+                                out.print("<hr/>");
+                                out.print("<br/>");
                                 out.print("<br/>");
                             }
                         }
                     }
-                } catch (Exception ex) {
-                    // TODO handle custom exceptions here
+                } else {
+                    // Ketika ada parameter untuk search
+                    String search = request.getParameter("search");
+                    String choice = request.getParameter("choice");
+                    /* Melakukan Searching dengan Method search_product pada MarketService */
+                    try {
+                        int choice_int = 0;
+                        if (choice.equals("product")) {
+                            choice_int = 0;
+                        } else if (choice.equals("store")) {
+                            choice_int = 1;
+                        }
+
+                        List<Product> result = port.searchProduct(search, user_token, choice_int);
+
+                        /* Jika expired */
+                        if (result == null) {
+                            response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
+                                    + "message=expired");
+                        } else {
+                            if (result.size() == 0) {
+                                out.print("<p>Nothing matches your search.</p>");
+                            } else {
+                                for (int i = 0; i < result.size(); i++) {
+                                    out.print("<a href=\"\"><div ng-click=\"setReceiver('" + result.get(i).getUsername() + "')\"><b>" + result.get(i).getUsername() + "</a></b></div><br/>");
+                                    out.print("added this on " + result.get(i).getDate().getDate() + "</p></div>");
+                                    out.print("<hr/>");
+                                    out.print("<table>");
+                                    out.print("<tr class = \"container\">");
+                                    out.print("<td>");
+                                    out.print("<img \" width=120px height=120px src=\"" + result.get(i).getImage() + "\">");
+                                    out.print("</td>");
+                                    out.print("<td class=\"product_description\">");
+                                    out.print("<p class=\"catalog_title\">" + result.get(i).getName() + " <br/></p>");
+                                    out.print("<p class=\"catalog_price\">IDR " + result.get(i).getPrice() + "<br/></p>");
+                                    out.print("<p class=\"catalog_desc\">" + result.get(i).getDescription() + "</p>");
+                                    out.print("</td>");
+                                    out.print("<td class=\"product_misc\">");
+                                    out.print("<br/>");
+                                    out.print("<p>" + port.getLikes(result.get(i).getProductId()) + " likes </p><br/>");
+                                    out.print("<p>" + port.getPurchases(result.get(i).getProductId()) + " purchases <br/>");
+                                    out.print(port.isLiked(user_token, result.get(i).getProductId()));
+                                    out.print("<a href=\"http://localhost:8080/KAA-JSP/confirmation_purchase.jsp?token=" + user_token + "&product_id=" + result.get(i).getProductId() + "\"><p id=\"buy\">BUY</a></p>");
+                                    out.print("</td>");
+                                    out.print("</tr>");
+                                    out.print("</table>");
+                                    out.print("<hr/>");
+                                    out.print("<br/>");
+                                    out.print("<br/>");
+                                }
+                            }
+                        }
+                    } catch (Exception ex) {
+                        // TODO handle custom exceptions here
+                    }
                 }
-            }
-        %>
+            %>
 
-        {{user}}
-        <br>
-        <div class="popup-box chat-popup" id="1" ng-show="isReceiverSet()" style="right: 0px; display: block;">
-            <div class="popup-head">
-                <div class="popup-head-left">{{receiver}}</div>
-                <div class="popup-head-right" ng-click="setReceiver('')"><a href="">&#10005;</a></div>
-                <div style="clear: both"></div>
+            {{user}}
+            <br>
+            <div class="popup-box chat-popup" id="1" ng-show="isReceiverSet()" style="right: 0px; display: block;">
+                <div class="popup-head">
+                    <div class="popup-head-left">{{receiver}}</div>
+                    <div class="popup-head-right" ng-click="setReceiver('')"><a href="">&#10005;</a></div>
+                    <div style="clear: both"></div>
+                </div>
+                <div class="popup-messages">
+                    <ul>
+                        <li ng-repeat="message in messages" style="list-style-type:none">
+                            <div class="chatbubble" ng-if="message.name===receiver" style="float:left">{{message.text}}</div>
+                            <div class="chatbubble" ng-if="message.name===user" style="float:right">{{message.text}}</div>
+                        </li>
+                </div>
+                <div class="popup-input">
+                    <input type="text" style="height: 100%; width:80%" name="chat" class="auto-style1" hidefocus="hidefocus" ng-model="newmessage"/>
+                    <button ng-click="sendMessage()">Send</button>
+                </div>          
             </div>
-            <div class="popup-messages">
-                <ul>
-                    <li ng-repeat="message in messages" style="list-style-type:none">
-                        <div class="chatbubble" ng-if="message.name===receiver" style="float:left">{{message.text}}</div>
-                        <div class="chatbubble" ng-if="message.name===user" style="float:right">{{message.text}}</div>
-                    </li>
-            </div>
-            <div class="popup-input">
-                <input type="text" style="height: 100%; width:80%" name="chat" class="auto-style1" hidefocus="hidefocus" ng-model="newmessage"/>
-                <button ng-click="sendMessage()">Send</button>
-            </div>          
-        </div>
             
 <!--        <div ng-app="chatApp" ng-controller="chatController">
             <p>Name: <input type="text" ng-model="newmessage.user"></p>
@@ -433,9 +359,22 @@
 	</div> -->
         
 
-        <script>       
-            /*document.getElementById("catalog").style.background="#0066ff";
-            document.getElementById("catalog").style.color="#ffffff";*/
-        </script>
+            <!--        <div ng-app="chatApp" ng-controller="chatController">
+                        <p>Name: <input type="text" ng-model="newmessage.user"></p>
+                        <p>Message: <input type="text" ng-model="newmessage.text"></p>
+                        <button ng-click="insert(newmessage)">Send</button>
+                    
+                        <ul>
+                            <li ng-repeat="message in messages">
+                                {{message.user}} send: {{message.text}}
+                            </li>
+                        </ul>
+                    </div> -->
+
+
+            <script>
+                /*document.getElementById("catalog").style.background="#0066ff";
+                 document.getElementById("catalog").style.color="#ffffff";*/
+            </script>
     </body>
 </html>
diff --git a/KAA-JSP/build/web/css/style.css b/KAA-JSP/build/web/css/style.css
index 56b269fb3a26a4df0fb018b8a7346bd68258852b..5350b7a87048e7bc7870a57c1e2e10011348ebcb 100644
--- a/KAA-JSP/build/web/css/style.css
+++ b/KAA-JSP/build/web/css/style.css
@@ -337,4 +337,23 @@ a {
 
 .link{
 	color: #1a53ff;
+}
+
+ul {
+    margin: 0px 0px 0px 20px;
+    padding: 0px 0px 0px 10px;
+}
+
+ul li .on {
+    color: green;
+    list-style-type: disc;
+}
+
+ul li .off {
+    color: gray;
+    list-style-type: disc;
+}
+
+ul li span{
+    color: black;
 }
\ No newline at end of file
diff --git a/KAA-JSP/build/web/gfv3ee6.dpf b/KAA-JSP/build/web/gfv3ee6.dpf
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/KAA-JSP/build/web/login.jsp b/KAA-JSP/build/web/login.jsp
index c29577b374c28a081ffc749aef016bcc5b850233..cd0328d6b2b822fdfde657161a327a78bd869c41 100644
--- a/KAA-JSP/build/web/login.jsp
+++ b/KAA-JSP/build/web/login.jsp
@@ -9,36 +9,44 @@
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
 <!DOCTYPE html>
 <html>
-     <%
+    <%
         /* Check the request */
-        if (request.getParameter("submit") != null){
+        if (request.getParameter("submit") != null) {
             URL obj = null;
-            try{
+            try {
                 /* Consuming API using GET method */
                 String user = request.getParameter("username");
                 String pass = request.getParameter("password");
-                String urlParameter = "username="+user+"&password="+pass;
+                String urlParameter = "username=" + user + "&password=" + pass;
                 String userAgent = request.getHeader("user-agent");
                 String urlRequest = "http://localhost:8080/IdentService/login?";
-                RestAPI_consumer consumer = new RestAPI_consumer(urlRequest,urlParameter);
+                RestAPI_consumer consumer = new RestAPI_consumer(urlRequest, urlParameter);
                 consumer.execute();
                 JSONObject responseJSON = consumer.getOutput();
+
+                // REST API for Chat Service
+                String chattoken = (String) request.getParameter("chattoken");
+                Long uid = (Long) responseJSON.get("user_id");
+                String username = (String) responseJSON.get("username");
+                String urlParameter2 = "chattoken=" + chattoken + "&username=" + username;
+                out.println(urlParameter2);
+                String urlRequest2 = "http://localhost:8080/ChatService/TokenSaver?";
+                RestAPI_consumer consumer2 = new RestAPI_consumer(urlRequest2, urlParameter2);
+                consumer2.execute();
                 
                 /* Checking the response */
-                String status = (String)responseJSON.get("status");
-                String generatedToken = (String)responseJSON.get("token");
-                if (status.equals("OK")){
-                    Cookie cookie = new Cookie("token",generatedToken);
+                String status = (String) responseJSON.get("status");
+                String generatedToken = (String) responseJSON.get("token");
+                if (status.equals("OK")) {
+                    Cookie cookie = new Cookie("token", generatedToken);
                     response.addCookie(cookie);
                     response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
-                            + "jsp?token="+generatedToken);
-                }
-                else{
+                            + "jsp?token=" + generatedToken);
+                } else {
                     response.sendRedirect("http://localhost:8080/KAA-JSP/login."
                             + "jsp?message=error");
                 }
-            }
-            catch(Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
             }
         }
@@ -46,31 +54,32 @@
     <link href="css/style.css" rel="stylesheet" type="text/css"/>
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-	<title>Sale Project - Login</title>
-	<link href="css/style.css" rel="stylesheet" type="text/css">        
+        <title>Sale Project - Login</title>
+        <link href="css/style.css" rel="stylesheet" type="text/css">        
     </head>
-    <body onload="getChatToken()">
-	<div class="content">
+
+    <body>
+        <div class="content">
             <div class="logo">
-                    <span id="red">Sale</span><span id="blue">Project</span>
+                <span id="red">Sale</span><span id="blue">Project</span>
             </div>
             <div class="title">
                 Please login
             </div>
             <hr>
             <div>
-            <form method= "GET">
-                <div class="input_field">
-                    Email or username<br><input type="text" name="username"><br>
-                </div>
-                <div class="input_field">
-                    Password<br><input type="password" name="password"><br>
-                </div>
-                <input type="hidden" name="chattoken" id="chattoken" value="">
-                <div class="submit_button_add">
-                    <input type="submit" name ="submit" value="LOGIN">
-                </div>
-            </form>
+                <form method= "GET">
+                    <div class="input_field">
+                        Email or username<br><input type="text" name="username"><br>
+                    </div>
+                    <div class="input_field">
+                        Password<br><input type="password" name="password"><br>
+                    </div>
+                    <input type="hidden" name="chattoken" id="chattoken">
+                    <div class="submit_button_add">
+                        <input type="submit" name ="submit" value="LOGIN">
+                    </div>
+                </form>
             </div>
             <div>
                 <br/>
@@ -80,61 +89,48 @@
                 <br />
                 <%
                     /* Printing the message */
-                    if (request.getParameter("message") != null){
+                    if (request.getParameter("message") != null) {
                         String message = request.getParameter("message");
                         if (message.equals("error")) {
                             out.println("Login Failed");
-                        }
-                        else if (message.equals("logout")){
+                        } else if (message.equals("logout")) {
                             out.println("Logged out!");
-                        }
-                        else if (message.equals("expired")){
+                        } else if (message.equals("expired")) {
                             out.println("Your token has expired!");
-                        }
-                        else{
+                        } else {
                             out.println(request.getParameter("message").toString());
                         }
                     }
                 %>
             </div>
-	</div>
+        </div>
         <script src="https://www.gstatic.com/firebasejs/3.6.1/firebase.js"></script>
         <script>
-          // Initialize Firebase
-          // Initialize Firebase
-        /*var config = {
-          apiKey: "AIzaSyAQ2WIB6GWOxmtwMdGd8eHawL4PWxK8evU",
-          authDomain: "tugas-besar-wbd.firebaseapp.com",
-          databaseURL: "https://tugas-besar-wbd.firebaseio.com",
-          storageBucket: "tugas-besar-wbd.appspot.com",
-          messagingSenderId: "1049009619420"
-        };
-          firebase.initializeApp(config);
-          
-          const messaging = firebase.messaging();
-          messaging.requestPermission()
-            .then(function(){
-               console.log('Have Permission');
-               return messaging.getToken();
-                })
-            .then(function(token){
-                console.log(token);
-                })
-            .catch(function(err){
-                console.log('Errorr');
-            })
-            */
+            // Initialize Firebase
+            // Initialize Firebase
+            /*var config = {
+             apiKey: "AIzaSyAQ2WIB6GWOxmtwMdGd8eHawL4PWxK8evU",
+             authDomain: "tugas-besar-wbd.firebaseapp.com",
+             databaseURL: "https://tugas-besar-wbd.firebaseio.com",
+             storageBucket: "tugas-besar-wbd.appspot.com",
+             messagingSenderId: "1049009619420"
+             };
+             firebase.initializeApp(config);
+             
+             const messaging = firebase.messaging();
+             messaging.requestPermission()
+             .then(function(){
+             console.log('Have Permission');
+             return messaging.getToken();
+             })
+             .then(function(token){
+             console.log(token);
+             })
+             .catch(function(err){
+             console.log('Errorr');
+             })
+             */
         </script>
-        <%
-            JSONObject json2 = new JSONObject();
-            JSONObject json1 = new JSONObject();
-            //String chattoken =rs.getString("chattoken");
-            json2.put("to", "XXX");
-            json2.put("username","Ali");
-            json1.put("message","Masbro");
-            json2.put("data",json1);
-            System.out.println(json2.toString());
-        %>
         <!-- Firebase -->
         <script src="https://www.gstatic.com/firebasejs/3.6.1/firebase.js"></script>
         <script>
@@ -146,23 +142,25 @@
                 messagingSenderId: "1049009619420"
             };
             firebase.initializeApp(config);
-
+            
             messaging = firebase.messaging();
 
             messaging.requestPermission()
-              .then(function() {
-                console.log('Notification permission granted.');
-                return messaging.getToken();
-                // TODO(developer): Retrieve an Instance ID token for use with FCM.
-                // ...
-                
-              })
-              .then(function(token){
-                  console.log(token);
-              })
-              .catch(function(err) {
-                console.log('Unable to get permission to notify.', err);
-              });
+                    .then(function () {
+                        console.log('Notification permission granted.');
+                        return messaging.getToken();
+                        // TODO(developer): Retrieve an Instance ID token for use with FCM.
+                        // ...
+
+                    })
+                    .then(function (token) {
+                        document.getElementById("chattoken").value = token;
+                        console.log(token);
+                    })
+                    .catch(function (err) {
+                        console.log('Unable to get permission to notify.', err);
+                    });
+
             
               var chattoken= messaging.getToken();
               
diff --git a/KAA-JSP/dist/KAA-JSP.war b/KAA-JSP/dist/KAA-JSP.war
index da3a21aee0d46caaf34457873a7ed4e9b7f8791c..98b39b01972830d16dfcc043dd0d739926aed9e0 100644
Binary files a/KAA-JSP/dist/KAA-JSP.war and b/KAA-JSP/dist/KAA-JSP.war differ
diff --git a/KAA-JSP/nbproject/private/private.xml b/KAA-JSP/nbproject/private/private.xml
index 6da6550e64719b72ac203cddfaca0988573087e6..81c982e259c6d22a97d5e96265819faf6c8422a7 100644
--- a/KAA-JSP/nbproject/private/private.xml
+++ b/KAA-JSP/nbproject/private/private.xml
@@ -3,11 +3,13 @@
     <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
     <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
         <group>
-            <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/KAA-JSP/web/css/style.css</file>
             <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/KAA-JSP/web/catalog.jsp</file>
             <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/KAA-JSP/web/scripts/app.js</file>
-            <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/KAA-JSP/src/java/org/saleproject/KAA/UploadProduct.java</file>
+            <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/KAA-JSP/web/purchases.jsp</file>
             <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/KAA-JSP/src/java/NewServlet.java</file>
+            <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/KAA-JSP/web/login.jsp</file>
+            <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/KAA-JSP/src/java/org/saleproject/KAA/UploadProduct.java</file>
+            <file>file:/home/khrs/GitProject/WBD/Tubes3/TugasBesar3_AngularJSandFirebase/KAA-JSP/web/css/style.css</file>
         </group>
     </open-files>
 </project-private>
diff --git a/KAA-JSP/web/catalog.jsp b/KAA-JSP/web/catalog.jsp
index 604e7be95fa2012001bad979e21691896d3bd703..0bba014676d93a65556830aada0cf368b2dd5f21 100644
--- a/KAA-JSP/web/catalog.jsp
+++ b/KAA-JSP/web/catalog.jsp
@@ -22,11 +22,11 @@
 <html>
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-	<title>Sale Project - Catalog</title>
-	<link href="css/style.css" rel="stylesheet" type="text/css">
+        <title>Sale Project - Catalog</title>
+        <link href="css/style.css" rel="stylesheet" type="text/css">
         <!-- Firebase -->
         <script src="https://www.gstatic.com/firebasejs/3.6.1/firebase.js"></script>
-         <!--Angular -->
+        <!--Angular -->
         <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
         <!--<script src="https://cdn.firebase.com/js/client/2.0.4/firebase.js"></script>--> 
         <!--<script src="https://www.gstatic.com/firebasejs/3.6.1/firebase-app.js"></script>
@@ -35,390 +35,316 @@
         <script src="https://www.gstatic.com/firebasejs/3.6.1/firebase-messaging.js"></script>
         <!-- <script src="https://www.gstatic.com/firebasejs/3.6.1/firebase-storage.js"></script> -->
         <!-- AngularFire -->
-<!--        <script src="https://cdn.firebase.com/libs/angularfire/0.9.2/angularfire.min.js"></script>-->
- 
-        <script>
-          // Initialize Firebase
+        <!--        <script src="https://cdn.firebase.com/libs/angularfire/0.9.2/angularfire.min.js"></script>-->
 
-          /*var config = {
-            apiKey: "AIzaSyAN43gCcqFx095nCBy-4abeRGkoZB1-Rok",
-            authDomain: "kaa-saleproject.firebaseapp.com",
-            databaseURL: "https://kaa-saleproject.firebaseio.com",
-            storageBucket: "kaa-saleproject.appspot.com",
-            messagingSenderId: "815161898662"
-          };*/
-/*        var config = {
-          apiKey: "AIzaSyAQ2WIB6GWOxmtwMdGd8eHawL4PWxK8evU",
-          authDomain: "tugas-besar-wbd.firebaseapp.com",
-          databaseURL: "https://tugas-besar-wbd.firebaseio.com",
-          storageBucket: "tugas-besar-wbd.appspot.com",
-          messagingSenderId: "1049009619420"
-        };
-          firebase.initializeApp(config);
-          
-          const messaging = firebase.messaging();
-          messaging.requestPermission()
-            .then(function() {
-              console.log('Notification permission granted.');
-              return messaging.getToken();
-              // TODO(developer): Retrieve an Instance ID token for use with FCM.
-              // ...
-            })
-            .then(function(token){
-                console.log(token); 
-            })
-            .catch(function(err) {
-              console.log('Unable to get permission to notify.', err);
-            });*/
-    
-    
-          /*messaging.requestPermission().then(function(){
-              console.log('Notification permission granted');
-              messaging.getToken().then(function(){
-                  if(currentToken){
-                      sendTokenToServer(currentToken);
-                      updateUIForPushEnabled(currentToken);
-                      console.log('Token retrieved, ',currentToken);
-                      //abis itu send ke tokensaver chatservice di sini atau di bawah
-                  } else {
-                      console.log('No Instance ID token available. Request permission to generate one');
-                      updateUIForPushPermissionRequired();
-                      setTokenToServer(false);
-                  }
-              }).catch(function(err){
-                  console.log('An error occured while retrieving token. ',err);
-                  showToken('Error retrieving Instance ID token. ',err);
-                  setTokenToServer(false);
-              });
-          }).catch(function(err){
-              console.log('Unable to get permission to notify',err);
-          });
-          
-          messaging.onTokenRefresh(function(){
-              mesagging.getToken().then(function(refreshedToken){
-                  console.log('Token refreshed.');
-                  setTokenSentToServer(false);
-                  sendTokenToServer(refreshedToken);
-              });
-          }).catch(function(err){
-              console.log('Unable to retrieve refreshed token. ',err);
-              showToken('Unable to retrieve refreshed token. ',err);
-          });
-          
-          messaging.onMessage(function(payload){
-              console.log("Message received. ",payload);
-          });*/
 
-        </script>
         <!--Application -->
         <script src="scripts/app.js"></script>
 
-        
+
     </head>
     <body ng-app="chatApp" ng-controller="chatController">
-	<div class="catalog_content">
-        <div class="logo">
-            <span id="red">Sale</span><span id="blue">Project</span>
-        </div>
-        <div class="information">
-       <span>
-        <%
-/*            FirebaseOptions options = new FirebaseOptions.Builder()
-            .setServiceAccount(new FileInputStream("path/to/serviceAccountKey.json"))
-            .setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/")
-            .build();
+        <div class="catalog_content">
+            <div class="logo">
+                <span id="red">Sale</span><span id="blue">Project</span>
+            </div>
+            <div class="information">
+                <span>
+                    <%
+                        /*            FirebaseOptions options = new FirebaseOptions.Builder()
+                        .setServiceAccount(new FileInputStream("path/to/serviceAccountKey.json"))
+                        .setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/")
+                        .build();
 
-            FirebaseApp.initializeApp(options);*/
-            
-            JSONObject responseJSON = new JSONObject();
-            JSONObject responseJSON1 = new JSONObject();
-            org.kaa.marketplaceservice.service.MarketPlaceService_Service service = new org.kaa.marketplaceservice.service.MarketPlaceService_Service();
-            org.kaa.marketplaceservice.service.MarketPlaceService port = service.getMarketPlaceServicePort();        
-            String query;
-            String APIURL;
-            String ParameterURL;
-            
-            /* Showing username of user */
-            String user_token = request.getParameter("token");
-            if (request.getParameter("like") != null){
-               String productId = request.getParameter("product_id");
-               boolean like;
-               if (request.getParameter("like").equals("yes")){
-                   like = true;
-               } else {
-                   like = false;
-               }
-               ProcedureStatus result = port.processLike(user_token, productId, like);
-               if (result.getStatus().equals("OK")){
-                   //Do nothing
-                } else if (result.getStatus().equals("EXPIRED")) {
-                    response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
-                                         + "message=Expired");
-                } else {
-                    response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
-                            + "jsp?token="+user_token+"&message=error");
-                }
-            }
-            
-            if ((request.getParameter("logout") == null) && 
-                    (request.getParameter("token")!= null)){
-                /* Consume REST API */
-                ParameterURL = "token="+ request.getParameter("token");
-                APIURL = "http://localhost:8080/IdentService/validate?";
-                RestAPI_consumer consumer = new RestAPI_consumer(APIURL,ParameterURL);
-                consumer.execute();
-                responseJSON = consumer.getOutput();
-                
-                /* Checking the response */
-                String status = (String)responseJSON.get("status");
-                if (status.equals("OK")){
-                        String user = (String)responseJSON.get("user_name");
-                        out.println("Hello, " + user);
-                        //out.println("<script>setUser('"+user+"');</script>");
-                }
-                else{
-                        response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
-                                        + "jsp?token="+user_token);
-                }
-            }
-            /* Logout */
-            else if ((request.getParameter("logout") != null) && 
-                    (request.getParameter("token")!= null)){
-                URL obj1 = null;
-                try{
-                    /* Consume REST API */
-                    ParameterURL = "token="+ user_token;
-                    APIURL = "http://localhost:8080/IdentService/logout?";
-                    RestAPI_consumer consumer1 = new RestAPI_consumer(APIURL,ParameterURL);
-                    consumer1.execute();
-                    responseJSON1 = consumer1.getOutput();
-                    
-                    /* Checking the response */
-                    String status1 = (String)responseJSON1.get("status");
-                    if (status1.equals("OK")){
-                        response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
-                                + "message=logout");
-                    }
-                    else{
-                        response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
-                                + "jsp?token="+user_token);
-                    }
-                }
-                catch(Exception e){
-                    e.printStackTrace();
-                }
-            }
+                        FirebaseApp.initializeApp(options);*/
 
-            /*          Firebase here  
-            String uid = "some-uid";
+                        JSONObject responseJSON = new JSONObject();
+                        JSONObject responseJSON1 = new JSONObject();
+                        org.kaa.marketplaceservice.service.MarketPlaceService_Service service = new org.kaa.marketplaceservice.service.MarketPlaceService_Service();
+                        org.kaa.marketplaceservice.service.MarketPlaceService port = service.getMarketPlaceServicePort();
+                        String query;
+                        String APIURL;
+                        String ParameterURL;
 
-            FirebaseAuth.getInstance().createCustomToken(uid)
-                .addOnSuccessListener(new OnSuccessListener<String>() {
-                    @Override
-                    public void onSuccess(String customToken) {
-                        // Send token back to client
-                    }
-                });*/
-        %>
-        </span>
+                        String urlParamChat;
+                        String urlRequest2 = "http://localhost:8080/ChatService/RetrieveStatus?";
 
-        </br>
-            <a href="
-            <%
-                String logoutURL = "http://localhost:8080/KAA-JSP/catalog.jsp?token="+user_token+"&logout=on";
-                out.println(logoutURL);
-            %>
-               " class="logout"><span class="link">Logout</span>
-            </a><br/>
-        </div>
-        <table class="menu">
-            <th class="menupart" id="active">
-                <a href="
-                   <%
-                    out.println("http://localhost:8080/KAA-JSP/catalog.jsp?token="+user_token);
-                   %>
-                   ">
-                    Catalog
-                </a>
-            </th>
-            <th class="menupart">
-                <a href="
-                   <%
-                    out.println("http://localhost:8080/KAA-JSP/yourproduct.jsp?token="+user_token);
-                   %>
-                   ">
-                    Your Products
-                </a>
-            </th>
-            <th class="menupart">
-                <a href="
-                   <%
-                    out.println("http://localhost:8080/KAA-JSP/addproduct.jsp?token="+user_token);
-                   %>
-                   ">
-                    Add Product
-                </a>
-            </th>
-            <th class="menupart">
-                <a href="
-                   <%
-                    out.println("http://localhost:8080/KAA-JSP/sales.jsp?token="+user_token);
-                   %>
-                   ">
-                    Sales
-                </a>
-            </th>
-            <th class="menupart">
+                        /* Showing username of user */
+                        String user_token = request.getParameter("token");
+                        if (request.getParameter("like") != null) {
+                            String productId = request.getParameter("product_id");
+                            boolean like;
+                            if (request.getParameter("like").equals("yes")) {
+                                like = true;
+                            } else {
+                                like = false;
+                            }
+                            ProcedureStatus result = port.processLike(user_token, productId, like);
+                            if (result.getStatus().equals("OK")) {
+                                //Do nothing
+                            } else if (result.getStatus().equals("EXPIRED")) {
+                                response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
+                                        + "message=Expired");
+                            } else {
+                                response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
+                                        + "jsp?token=" + user_token + "&message=error");
+                            }
+                        }
+
+                        if ((request.getParameter("logout") == null)
+                                && (request.getParameter("token") != null)) {
+                            /* Consume REST API */
+                            ParameterURL = "token=" + request.getParameter("token");
+                            APIURL = "http://localhost:8080/IdentService/validate?";
+                            RestAPI_consumer consumer = new RestAPI_consumer(APIURL, ParameterURL);
+                            consumer.execute();
+                            responseJSON = consumer.getOutput();
+
+                            /* Checking the response */
+                            String status = (String) responseJSON.get("status");
+                            if (status.equals("OK")) {
+                                String user = (String) responseJSON.get("user_name");
+                                out.println("Hello, " + user);
+                                //out.println("<script>setUser('"+user+"');</script>");
+                            } else {
+                                response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
+                                        + "jsp?token=" + user_token);
+                            }
+                        } /* Logout */ else if ((request.getParameter("logout") != null)
+                                && (request.getParameter("token") != null)) {
+                            URL obj1 = null;
+                            try {
+                                /* Consume REST API */
+                                ParameterURL = "token=" + user_token;
+                                APIURL = "http://localhost:8080/IdentService/logout?";
+                                RestAPI_consumer consumer1 = new RestAPI_consumer(APIURL, ParameterURL);
+                                consumer1.execute();
+                                responseJSON1 = consumer1.getOutput();
+
+                                /* Checking the response */
+                                String status1 = (String) responseJSON1.get("status");
+                                if (status1.equals("OK")) {
+                                    response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
+                                            + "message=logout");
+                                } else {
+                                    response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
+                                            + "jsp?token=" + user_token);
+                                }
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        }
+
+
+                    %>
+                </span>
+
+                </br>
                 <a href="
-                   <%
-                    out.println("http://localhost:8080/KAA-JSP/purchases.jsp?token="+user_token);
+                   <%                String logoutURL = "http://localhost:8080/KAA-JSP/catalog.jsp?token=" + user_token + "&logout=on";
+                       out.println(logoutURL);
                    %>
-                   ">Purchases
-                </a>
-            </th>
-        </table>
-        <br/>
-        <p class="title">What are you going to buy today?</p>
-        <hr/>
-        <br/>
-        <div class="add_product_content">
+                   " class="logout"><span class="link">Logout</span>
+                </a><br/>
+            </div>
+            <table class="menu">
+                <th class="menupart" id="active">
+                    <a href="
+                       <%
+                           out.println("http://localhost:8080/KAA-JSP/catalog.jsp?token=" + user_token);
+                       %>
+                       ">
+                        Catalog
+                    </a>
+                </th>
+                <th class="menupart">
+                    <a href="
+                       <%
+                           out.println("http://localhost:8080/KAA-JSP/yourproduct.jsp?token=" + user_token);
+                       %>
+                       ">
+                        Your Products
+                    </a>
+                </th>
+                <th class="menupart">
+                    <a href="
+                       <%
+                           out.println("http://localhost:8080/KAA-JSP/addproduct.jsp?token=" + user_token);
+                       %>
+                       ">
+                        Add Product
+                    </a>
+                </th>
+                <th class="menupart">
+                    <a href="
+                       <%
+                           out.println("http://localhost:8080/KAA-JSP/sales.jsp?token=" + user_token);
+                       %>
+                       ">
+                        Sales
+                    </a>
+                </th>
+                <th class="menupart">
+                    <a href="
+                       <%
+                           out.println("http://localhost:8080/KAA-JSP/purchases.jsp?token=" + user_token);
+                       %>
+                       ">Purchases
+                    </a>
+                </th>
+            </table>
+            <br/>
+            <p class="title">What are you going to buy today?</p>
+            <hr/>
+            <br/>
+            <div class="add_product_content">
                 <form method="GET" enctype="multipart/form-data">
-                        <div class="input_catalog">
-                                <input type="hidden" name="token" value=<%
-                                    out.println(user_token);
-                                %> >
-                                <input type="text" placeholder="Search catalog ..." 
-                                    name="search" style="width:90%; height: 35px; border:none;" 
-                                    class="auto-style1" hidefocus="hidefocus">
-                                <input type="submit" value="GO" style="width: 10%; height: 35px; font-weight: bold"><br/>
-                                by
-                                <input class="radio" type="radio" name="choice" value="product" checked="checked" />
-                                <label><span>product</span></label><br />
-                                <input class="radio" type="radio" name="choice" value="store" style="margin-left:25px;" />
-                                <label><span>store</span></label>
-                        </div>
+                    <div class="input_catalog">
+                        <input type="hidden" name="token" value=<%
+                            out.println(user_token);
+                               %> >
+                        <input type="text" placeholder="Search catalog ..." 
+                               name="search" style="width:90%; height: 35px; border:none;" 
+                               class="auto-style1" hidefocus="hidefocus">
+                        <input type="submit" value="GO" style="width: 10%; height: 35px; font-weight: bold"><br/>
+                        by
+                        <input class="radio" type="radio" name="choice" value="product" checked="checked" />
+                        <label><span>product</span></label><br />
+                        <input class="radio" type="radio" name="choice" value="store" style="margin-left:25px;" />
+                        <label><span>store</span></label>
+                    </div>
                 </form>
-        </div>    
-        <%
-            if(request.getParameter("search") == null){
-                // Ketika pertama kali membuka catalog (tidak ada parameter search) 
-                List<Product> result = port.retrieveAllProduct(user_token);
-                
-                // Ketika token sudah expired
-                if (result == null){
-                        response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
-                                + "message=expired");
-                } else {
-                    if (result.size() == 0){
-                            out.print("<p>No product to be sold.</p>");
-                    } else {
-                        for (int i = 0; i < result.size(); i++) {
-                            out.print("<a href=\"\"><div ng-click=\"setReceiver('"+result.get(i).getUsername()+"')\"><p><b>" + result.get(i).getUsername() + "</a></b><br/>");
-                            out.print("added this on " + result.get(i).getDate().getDate() + "</p></div>");
-                            out.print("<hr/>");
-                            out.print("<table>");
-                            out.print("<tr class = \"container\">");
-                            out.print("<td>");
-                            out.print("<img \" width=120px height=120px src=\"" + result.get(i).getImage() + "\">");                                                       
-                            out.print("</td>");                                                     
-                            out.print("<td class=\"product_description\">");                                                             
-                            out.print("<p class=\"catalog_title\">" + result.get(i).getName() + " <br/></p>");                                                               
-                            out.print("<p class=\"catalog_price\">IDR " + result.get(i).getPrice() + "<br/></p>");                                                               
-                            out.print("<p class=\"catalog_desc\">" + result.get(i).getDescription() + "</p>");                                                        
-                            out.print("</td>");                                                        
-                            out.print("<td class=\"product_misc\">");                                                               
-                            out.print("<br/>");                                                               
-                            out.print("<p>" + port.getLikes(result.get(i).getProductId()) + " likes </p><br/>");                                                                     
-                            out.print("<p>" + port.getPurchases(result.get(i).getProductId()) + " purchases <br/>");  
-                            out.print(port.isLiked(user_token, result.get(i).getProductId()));                                                                        
-                            out.print("<a href=\"http://localhost:8080/KAA-JSP/confirmation_purchase.jsp?token=" + user_token + "&product_id=" + result.get(i).getProductId() + "\"><p id=\"buy\">BUY</a></p>");                                                                
-                            out.print("</td>");                                                       
-                            out.print("</tr>");                                                
-                            out.print("</table>");                                                
-                            out.print("<hr/>");                                               
-                            out.print("<br/>");                                              
-                            out.print("<br/>");
-                        }
-                    }
-                }
-           } else {
-                // Ketika ada parameter untuk search
-                String search = request.getParameter("search");
-                String choice = request.getParameter("choice");
-                /* Melakukan Searching dengan Method search_product pada MarketService */
-                try{
-                    int choice_int = 0;
-                    if (choice.equals("product")){
-                        choice_int = 0;
-                    } else if (choice.equals("store")) {
-                        choice_int = 1;
-                    }
-                    
-                    List<Product> result = port.searchProduct(search, user_token, choice_int);
-                    
-                    /* Jika expired */
-                    if (result == null){
+            </div>    
+            <%
+                if (request.getParameter("search") == null) {
+                    // Ketika pertama kali membuka catalog (tidak ada parameter search) 
+                    List<Product> result = port.retrieveAllProduct(user_token);
+
+                    // Ketika token sudah expired
+                    if (result == null) {
                         response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
                                 + "message=expired");
                     } else {
-                        if (result.size() == 0){
-                            out.print("<p>Nothing matches your search.</p>");
+                        if (result.size() == 0) {
+                            out.print("<p>No product to be sold.</p>");
                         } else {
                             for (int i = 0; i < result.size(); i++) {
-                                out.print("<a href=\"\"><div ng-click=\"setReceiver('"+result.get(i).getUsername()+"')\"><b>" + result.get(i).getUsername() + "</a></b></div><br/>");
+                                urlParamChat = "username=" + result.get(i).getUsername();
+                                RestAPI_consumer consumer2 = new RestAPI_consumer(urlRequest2, urlParamChat);
+                                consumer2.execute();
+                                responseJSON = consumer2.getOutput();
+                                if (responseJSON.get("status").equals("ON")) {
+                                    out.print("<img style=\"border: none; padding: 0px 10px 0px 0px; float:left\" height=15px width=15px src=\"img/on.png\">");
+                                    out.print("<a href=\"\"><div ng-click=\"setReceiver('" + result.get(i).getUsername() + "')\"><p><b>" + result.get(i).getUsername() + "</a></b><br/>");
+                                } else {
+                                    out.print("<img style=\"border: none; padding: 0px 10px 0px 0px; float:left\" height=15px width=15px src=\"img/off.png\">");
+                                    out.print("<a href=\"\"><div ng-click=\"setReceiver('" + result.get(i).getUsername() + "')\"><p><b>" + result.get(i).getUsername() + "</a></b><br/>");
+                                }
                                 out.print("added this on " + result.get(i).getDate().getDate() + "</p></div>");
                                 out.print("<hr/>");
                                 out.print("<table>");
                                 out.print("<tr class = \"container\">");
                                 out.print("<td>");
-                                out.print("<img \" width=120px height=120px src=\"" + result.get(i).getImage() + "\">");                                                       
-                                out.print("</td>");                                                     
-                                out.print("<td class=\"product_description\">");                                                             
-                                out.print("<p class=\"catalog_title\">" + result.get(i).getName() + " <br/></p>");                                                               
-                                out.print("<p class=\"catalog_price\">IDR " + result.get(i).getPrice() + "<br/></p>");                                                               
-                                out.print("<p class=\"catalog_desc\">" + result.get(i).getDescription() + "</p>");                                                        
-                                out.print("</td>");                                                        
-                                out.print("<td class=\"product_misc\">");                                                               
-                                out.print("<br/>");                                                               
-                                out.print("<p>" + port.getLikes(result.get(i).getProductId()) + " likes </p><br/>");                                                                     
-                                out.print("<p>" + port.getPurchases(result.get(i).getProductId()) + " purchases <br/>");  
-                                out.print(port.isLiked(user_token, result.get(i).getProductId()));                                                                        
-                                out.print("<a href=\"http://localhost:8080/KAA-JSP/confirmation_purchase.jsp?token=" + user_token + "&product_id=" + result.get(i).getProductId() + "\"><p id=\"buy\">BUY</a></p>");                                                                
-                                out.print("</td>");                                                       
-                                out.print("</tr>");                                                
-                                out.print("</table>");                                                
-                                out.print("<hr/>");                                               
-                                out.print("<br/>");                                              
+                                out.print("<img \" width=120px height=120px src=\"" + result.get(i).getImage() + "\">");
+                                out.print("</td>");
+                                out.print("<td class=\"product_description\">");
+                                out.print("<p class=\"catalog_title\">" + result.get(i).getName() + " <br/></p>");
+                                out.print("<p class=\"catalog_price\">IDR " + result.get(i).getPrice() + "<br/></p>");
+                                out.print("<p class=\"catalog_desc\">" + result.get(i).getDescription() + "</p>");
+                                out.print("</td>");
+                                out.print("<td class=\"product_misc\">");
+                                out.print("<br/>");
+                                out.print("<p>" + port.getLikes(result.get(i).getProductId()) + " likes </p><br/>");
+                                out.print("<p>" + port.getPurchases(result.get(i).getProductId()) + " purchases <br/>");
+                                out.print(port.isLiked(user_token, result.get(i).getProductId()));
+                                out.print("<a href=\"http://localhost:8080/KAA-JSP/confirmation_purchase.jsp?token=" + user_token + "&product_id=" + result.get(i).getProductId() + "\"><p id=\"buy\">BUY</a></p>");
+                                out.print("</td>");
+                                out.print("</tr>");
+                                out.print("</table>");
+                                out.print("<hr/>");
+                                out.print("<br/>");
                                 out.print("<br/>");
                             }
                         }
                     }
-                } catch (Exception ex) {
-                    // TODO handle custom exceptions here
+                } else {
+                    // Ketika ada parameter untuk search
+                    String search = request.getParameter("search");
+                    String choice = request.getParameter("choice");
+                    /* Melakukan Searching dengan Method search_product pada MarketService */
+                    try {
+                        int choice_int = 0;
+                        if (choice.equals("product")) {
+                            choice_int = 0;
+                        } else if (choice.equals("store")) {
+                            choice_int = 1;
+                        }
+
+                        List<Product> result = port.searchProduct(search, user_token, choice_int);
+
+                        /* Jika expired */
+                        if (result == null) {
+                            response.sendRedirect("http://localhost:8080/KAA-JSP/login.jsp?"
+                                    + "message=expired");
+                        } else {
+                            if (result.size() == 0) {
+                                out.print("<p>Nothing matches your search.</p>");
+                            } else {
+                                for (int i = 0; i < result.size(); i++) {
+                                    out.print("<a href=\"\"><div ng-click=\"setReceiver('" + result.get(i).getUsername() + "')\"><b>" + result.get(i).getUsername() + "</a></b></div><br/>");
+                                    out.print("added this on " + result.get(i).getDate().getDate() + "</p></div>");
+                                    out.print("<hr/>");
+                                    out.print("<table>");
+                                    out.print("<tr class = \"container\">");
+                                    out.print("<td>");
+                                    out.print("<img \" width=120px height=120px src=\"" + result.get(i).getImage() + "\">");
+                                    out.print("</td>");
+                                    out.print("<td class=\"product_description\">");
+                                    out.print("<p class=\"catalog_title\">" + result.get(i).getName() + " <br/></p>");
+                                    out.print("<p class=\"catalog_price\">IDR " + result.get(i).getPrice() + "<br/></p>");
+                                    out.print("<p class=\"catalog_desc\">" + result.get(i).getDescription() + "</p>");
+                                    out.print("</td>");
+                                    out.print("<td class=\"product_misc\">");
+                                    out.print("<br/>");
+                                    out.print("<p>" + port.getLikes(result.get(i).getProductId()) + " likes </p><br/>");
+                                    out.print("<p>" + port.getPurchases(result.get(i).getProductId()) + " purchases <br/>");
+                                    out.print(port.isLiked(user_token, result.get(i).getProductId()));
+                                    out.print("<a href=\"http://localhost:8080/KAA-JSP/confirmation_purchase.jsp?token=" + user_token + "&product_id=" + result.get(i).getProductId() + "\"><p id=\"buy\">BUY</a></p>");
+                                    out.print("</td>");
+                                    out.print("</tr>");
+                                    out.print("</table>");
+                                    out.print("<hr/>");
+                                    out.print("<br/>");
+                                    out.print("<br/>");
+                                }
+                            }
+                        }
+                    } catch (Exception ex) {
+                        // TODO handle custom exceptions here
+                    }
                 }
-            }
-        %>
+            %>
 
-        {{user}}
-        <br>
-        <div class="popup-box chat-popup" id="1" ng-show="isReceiverSet()" style="right: 0px; display: block;">
-            <div class="popup-head">
-                <div class="popup-head-left">{{receiver}}</div>
-                <div class="popup-head-right" ng-click="setReceiver('')"><a href="">&#10005;</a></div>
-                <div style="clear: both"></div>
+            {{user}}
+            <br>
+            <div class="popup-box chat-popup" id="1" ng-show="isReceiverSet()" style="right: 0px; display: block;">
+                <div class="popup-head">
+                    <div class="popup-head-left">{{receiver}}</div>
+                    <div class="popup-head-right" ng-click="setReceiver('')"><a href="">&#10005;</a></div>
+                    <div style="clear: both"></div>
+                </div>
+                <div class="popup-messages">
+                    <ul>
+                        <li ng-repeat="message in messages" style="list-style-type:none">
+                            <div class="chatbubble" ng-if="message.name===receiver" style="float:left">{{message.text}}</div>
+                            <div class="chatbubble" ng-if="message.name===user" style="float:right">{{message.text}}</div>
+                        </li>
+                </div>
+                <div class="popup-input">
+                    <input type="text" style="height: 100%; width:80%" name="chat" class="auto-style1" hidefocus="hidefocus" ng-model="newmessage"/>
+                    <button ng-click="sendMessage()">Send</button>
+                </div>          
             </div>
-            <div class="popup-messages">
-                <ul>
-                    <li ng-repeat="message in messages" style="list-style-type:none">
-                        <div class="chatbubble" ng-if="message.name===receiver" style="float:left">{{message.text}}</div>
-                        <div class="chatbubble" ng-if="message.name===user" style="float:right">{{message.text}}</div>
-                    </li>
-            </div>
-            <div class="popup-input">
-                <input type="text" style="height: 100%; width:80%" name="chat" class="auto-style1" hidefocus="hidefocus" ng-model="newmessage"/>
-                <button ng-click="sendMessage()">Send</button>
-            </div>          
-        </div>
             
 <!--        <div ng-app="chatApp" ng-controller="chatController">
             <p>Name: <input type="text" ng-model="newmessage.user"></p>
@@ -433,9 +359,22 @@
 	</div> -->
         
 
-        <script>       
-            /*document.getElementById("catalog").style.background="#0066ff";
-            document.getElementById("catalog").style.color="#ffffff";*/
-        </script>
+            <!--        <div ng-app="chatApp" ng-controller="chatController">
+                        <p>Name: <input type="text" ng-model="newmessage.user"></p>
+                        <p>Message: <input type="text" ng-model="newmessage.text"></p>
+                        <button ng-click="insert(newmessage)">Send</button>
+                    
+                        <ul>
+                            <li ng-repeat="message in messages">
+                                {{message.user}} send: {{message.text}}
+                            </li>
+                        </ul>
+                    </div> -->
+
+
+            <script>
+                /*document.getElementById("catalog").style.background="#0066ff";
+                 document.getElementById("catalog").style.color="#ffffff";*/
+            </script>
     </body>
 </html>
diff --git a/KAA-JSP/web/css/style.css b/KAA-JSP/web/css/style.css
index 56b269fb3a26a4df0fb018b8a7346bd68258852b..5350b7a87048e7bc7870a57c1e2e10011348ebcb 100644
--- a/KAA-JSP/web/css/style.css
+++ b/KAA-JSP/web/css/style.css
@@ -337,4 +337,23 @@ a {
 
 .link{
 	color: #1a53ff;
+}
+
+ul {
+    margin: 0px 0px 0px 20px;
+    padding: 0px 0px 0px 10px;
+}
+
+ul li .on {
+    color: green;
+    list-style-type: disc;
+}
+
+ul li .off {
+    color: gray;
+    list-style-type: disc;
+}
+
+ul li span{
+    color: black;
 }
\ No newline at end of file
diff --git a/KAA-JSP/web/img/off.png b/KAA-JSP/web/img/off.png
new file mode 100644
index 0000000000000000000000000000000000000000..ab25ccd0ba6ebcd24761b13779cfd0a0065d4356
Binary files /dev/null and b/KAA-JSP/web/img/off.png differ
diff --git a/KAA-JSP/web/img/on.png b/KAA-JSP/web/img/on.png
new file mode 100644
index 0000000000000000000000000000000000000000..25325bda7c1e388b2cd709242f7e16268f078c31
Binary files /dev/null and b/KAA-JSP/web/img/on.png differ
diff --git a/KAA-JSP/web/login.jsp b/KAA-JSP/web/login.jsp
index c29577b374c28a081ffc749aef016bcc5b850233..cd0328d6b2b822fdfde657161a327a78bd869c41 100644
--- a/KAA-JSP/web/login.jsp
+++ b/KAA-JSP/web/login.jsp
@@ -9,36 +9,44 @@
 <%@page contentType="text/html" pageEncoding="UTF-8"%>
 <!DOCTYPE html>
 <html>
-     <%
+    <%
         /* Check the request */
-        if (request.getParameter("submit") != null){
+        if (request.getParameter("submit") != null) {
             URL obj = null;
-            try{
+            try {
                 /* Consuming API using GET method */
                 String user = request.getParameter("username");
                 String pass = request.getParameter("password");
-                String urlParameter = "username="+user+"&password="+pass;
+                String urlParameter = "username=" + user + "&password=" + pass;
                 String userAgent = request.getHeader("user-agent");
                 String urlRequest = "http://localhost:8080/IdentService/login?";
-                RestAPI_consumer consumer = new RestAPI_consumer(urlRequest,urlParameter);
+                RestAPI_consumer consumer = new RestAPI_consumer(urlRequest, urlParameter);
                 consumer.execute();
                 JSONObject responseJSON = consumer.getOutput();
+
+                // REST API for Chat Service
+                String chattoken = (String) request.getParameter("chattoken");
+                Long uid = (Long) responseJSON.get("user_id");
+                String username = (String) responseJSON.get("username");
+                String urlParameter2 = "chattoken=" + chattoken + "&username=" + username;
+                out.println(urlParameter2);
+                String urlRequest2 = "http://localhost:8080/ChatService/TokenSaver?";
+                RestAPI_consumer consumer2 = new RestAPI_consumer(urlRequest2, urlParameter2);
+                consumer2.execute();
                 
                 /* Checking the response */
-                String status = (String)responseJSON.get("status");
-                String generatedToken = (String)responseJSON.get("token");
-                if (status.equals("OK")){
-                    Cookie cookie = new Cookie("token",generatedToken);
+                String status = (String) responseJSON.get("status");
+                String generatedToken = (String) responseJSON.get("token");
+                if (status.equals("OK")) {
+                    Cookie cookie = new Cookie("token", generatedToken);
                     response.addCookie(cookie);
                     response.sendRedirect("http://localhost:8080/KAA-JSP/catalog."
-                            + "jsp?token="+generatedToken);
-                }
-                else{
+                            + "jsp?token=" + generatedToken);
+                } else {
                     response.sendRedirect("http://localhost:8080/KAA-JSP/login."
                             + "jsp?message=error");
                 }
-            }
-            catch(Exception e){
+            } catch (Exception e) {
                 e.printStackTrace();
             }
         }
@@ -46,31 +54,32 @@
     <link href="css/style.css" rel="stylesheet" type="text/css"/>
     <head>
         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-	<title>Sale Project - Login</title>
-	<link href="css/style.css" rel="stylesheet" type="text/css">        
+        <title>Sale Project - Login</title>
+        <link href="css/style.css" rel="stylesheet" type="text/css">        
     </head>
-    <body onload="getChatToken()">
-	<div class="content">
+
+    <body>
+        <div class="content">
             <div class="logo">
-                    <span id="red">Sale</span><span id="blue">Project</span>
+                <span id="red">Sale</span><span id="blue">Project</span>
             </div>
             <div class="title">
                 Please login
             </div>
             <hr>
             <div>
-            <form method= "GET">
-                <div class="input_field">
-                    Email or username<br><input type="text" name="username"><br>
-                </div>
-                <div class="input_field">
-                    Password<br><input type="password" name="password"><br>
-                </div>
-                <input type="hidden" name="chattoken" id="chattoken" value="">
-                <div class="submit_button_add">
-                    <input type="submit" name ="submit" value="LOGIN">
-                </div>
-            </form>
+                <form method= "GET">
+                    <div class="input_field">
+                        Email or username<br><input type="text" name="username"><br>
+                    </div>
+                    <div class="input_field">
+                        Password<br><input type="password" name="password"><br>
+                    </div>
+                    <input type="hidden" name="chattoken" id="chattoken">
+                    <div class="submit_button_add">
+                        <input type="submit" name ="submit" value="LOGIN">
+                    </div>
+                </form>
             </div>
             <div>
                 <br/>
@@ -80,61 +89,48 @@
                 <br />
                 <%
                     /* Printing the message */
-                    if (request.getParameter("message") != null){
+                    if (request.getParameter("message") != null) {
                         String message = request.getParameter("message");
                         if (message.equals("error")) {
                             out.println("Login Failed");
-                        }
-                        else if (message.equals("logout")){
+                        } else if (message.equals("logout")) {
                             out.println("Logged out!");
-                        }
-                        else if (message.equals("expired")){
+                        } else if (message.equals("expired")) {
                             out.println("Your token has expired!");
-                        }
-                        else{
+                        } else {
                             out.println(request.getParameter("message").toString());
                         }
                     }
                 %>
             </div>
-	</div>
+        </div>
         <script src="https://www.gstatic.com/firebasejs/3.6.1/firebase.js"></script>
         <script>
-          // Initialize Firebase
-          // Initialize Firebase
-        /*var config = {
-          apiKey: "AIzaSyAQ2WIB6GWOxmtwMdGd8eHawL4PWxK8evU",
-          authDomain: "tugas-besar-wbd.firebaseapp.com",
-          databaseURL: "https://tugas-besar-wbd.firebaseio.com",
-          storageBucket: "tugas-besar-wbd.appspot.com",
-          messagingSenderId: "1049009619420"
-        };
-          firebase.initializeApp(config);
-          
-          const messaging = firebase.messaging();
-          messaging.requestPermission()
-            .then(function(){
-               console.log('Have Permission');
-               return messaging.getToken();
-                })
-            .then(function(token){
-                console.log(token);
-                })
-            .catch(function(err){
-                console.log('Errorr');
-            })
-            */
+            // Initialize Firebase
+            // Initialize Firebase
+            /*var config = {
+             apiKey: "AIzaSyAQ2WIB6GWOxmtwMdGd8eHawL4PWxK8evU",
+             authDomain: "tugas-besar-wbd.firebaseapp.com",
+             databaseURL: "https://tugas-besar-wbd.firebaseio.com",
+             storageBucket: "tugas-besar-wbd.appspot.com",
+             messagingSenderId: "1049009619420"
+             };
+             firebase.initializeApp(config);
+             
+             const messaging = firebase.messaging();
+             messaging.requestPermission()
+             .then(function(){
+             console.log('Have Permission');
+             return messaging.getToken();
+             })
+             .then(function(token){
+             console.log(token);
+             })
+             .catch(function(err){
+             console.log('Errorr');
+             })
+             */
         </script>
-        <%
-            JSONObject json2 = new JSONObject();
-            JSONObject json1 = new JSONObject();
-            //String chattoken =rs.getString("chattoken");
-            json2.put("to", "XXX");
-            json2.put("username","Ali");
-            json1.put("message","Masbro");
-            json2.put("data",json1);
-            System.out.println(json2.toString());
-        %>
         <!-- Firebase -->
         <script src="https://www.gstatic.com/firebasejs/3.6.1/firebase.js"></script>
         <script>
@@ -146,23 +142,25 @@
                 messagingSenderId: "1049009619420"
             };
             firebase.initializeApp(config);
-
+            
             messaging = firebase.messaging();
 
             messaging.requestPermission()
-              .then(function() {
-                console.log('Notification permission granted.');
-                return messaging.getToken();
-                // TODO(developer): Retrieve an Instance ID token for use with FCM.
-                // ...
-                
-              })
-              .then(function(token){
-                  console.log(token);
-              })
-              .catch(function(err) {
-                console.log('Unable to get permission to notify.', err);
-              });
+                    .then(function () {
+                        console.log('Notification permission granted.');
+                        return messaging.getToken();
+                        // TODO(developer): Retrieve an Instance ID token for use with FCM.
+                        // ...
+
+                    })
+                    .then(function (token) {
+                        document.getElementById("chattoken").value = token;
+                        console.log(token);
+                    })
+                    .catch(function (err) {
+                        console.log('Unable to get permission to notify.', err);
+                    });
+
             
               var chattoken= messaging.getToken();
               
diff --git a/MarketPlaceService/dist/MarketPlaceService.war b/MarketPlaceService/dist/MarketPlaceService.war
index 3669d98d5ed79bfdbf33696864a262a4332b7a5d..fd059c10f729d75c0fcf35a07b86acccf2b603e2 100644
Binary files a/MarketPlaceService/dist/MarketPlaceService.war and b/MarketPlaceService/dist/MarketPlaceService.war differ
diff --git a/chattoken.sql b/chattoken.sql
new file mode 100644
index 0000000000000000000000000000000000000000..f7cfae41c527872fa30f6d9baed68d00376aef74
--- /dev/null
+++ b/chattoken.sql
@@ -0,0 +1,53 @@
+-- phpMyAdmin SQL Dump
+-- version 4.5.1
+-- http://www.phpmyadmin.net
+--
+-- Host: 127.0.0.1
+-- Generation Time: Nov 29, 2016 at 10:36 PM
+-- Server version: 10.1.16-MariaDB
+-- PHP Version: 5.6.24
+
+SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
+SET time_zone = "+00:00";
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+
+--
+-- Database: `chattoken`
+--
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `chattoken`
+--
+
+CREATE TABLE `chattoken` (
+  `chattoken` varchar(4096) NOT NULL,
+  `user_id` int(15) NOT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
+-- Dumping data for table `chattoken`
+--
+
+INSERT INTO `chattoken` (`chattoken`, `user_id`) VALUES
+('fCstHDVcJFU:APA91bFGWLstDAZsMrLoFNdEWIGTIhq7xtdHXHXAc9jLYHnAdD8tLf1sIz8vfIjgTon21KPJtWMPWVTz1lhppU6vB-moNw71sWb8ibQxdLp5XWfC3_8oRKtByWuEcJWQxRryvVLuRlED', 11);
+
+--
+-- Indexes for dumped tables
+--
+
+--
+-- Indexes for table `chattoken`
+--
+ALTER TABLE `chattoken`
+  ADD PRIMARY KEY (`user_id`);
+
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;