Cookies are used at client side to store useful information. Following code snippet shows how to set a cookie in JSP.

Java Code:
<%
        Cookie myCookie= new Cookie("myCookie", "Welcome!");
        myCookie.setMaxAge(24 * 60 * 60);
        response.addCookie(myCookie); 
%>