All Examples This Package
java.lang.Object | +----javax.servlet.GenericServlet | +----javax.servlet.http.HttpServlet | +----examples.servlets.CookieCounter
Compile the servlet using the following line:
javac -d %SERVLET_CLASSES% CookieCounter.java
Copy the file "cookie.jpg" to:
doc_root/images/cookie.jpgWhere doc_root is the document root of your WebLogic Server. This is usually set to the "public_html" directory in your "myserver" directory. See Setting the document root for more details.
Register the servlet in the weblogic.properties file by adding (or uncommenting) the following lines:
weblogic.httpd.register.cookies=examples.servlets.CookieCounter
Start (or restart) the WebLogic Server, and use a web browser to visit the following URL: http://localhost:7001/cookies
Although this is an unusually short-lived cookie, you may easily see the cookie count up, then expire by reloading the page several times, waiting more than 10 seconds, then reloading the page again. Try turning off cookies in your browser, the servlet no longer works. For a failsafe way to handle non-cookie-friendly web browsers, see the SessionServlet example.
public CookieCounter()
public void init(ServletConfig config) throws ServletException
public void service(HttpServletRequest req, HttpServletResponse res) throws IOException
All Examples This Package