I am very confused how to set cookie in Javascript and than fetch it in jsp, I have tried a lot but all im vain
            Asked
            
        
        
            Active
            
        
            Viewed 685 times
        
    1 Answers
-1
            js code to add cookie
document.cookie = "username=Chirag; expires=Fri, 16 Mar 2018 12:00:00 UTC; path=/";
and to retrive cookie add this to your jsp code
<%
    Cookie[] cookies = request.getCookies();
    String username = null;
    for(Cookie cookie : cookies) {
        if("username".equals(cookie.getName())){
            username = cookie.getValue();
        }
    }
%>
additional resources Cookie in JavaScript
 
    
    
        Chirag
        
- 555
- 1
- 5
- 20
