CORE API / NOTES</>↗Core API27 Jun 2007
package org.kodejava.lang; public class StringBuilderInsert { public static void main(String[] args) { StringBuilder alphabets = new StringBuilder("abcdfghopqrstuvwxyz"); System.out.println("alphabets = " + alphabets); // |a|b|c|d|f|g|h|i|…. // 0|1|2|3|4|5|6|7|8|… // // From the above sequence you can see that the index of the string is // started from 0, so when we insert a string in the fourth […]
CORE API / NOTES</>↗Core API25 Jun 2007
This example demonstrate you how to use the StringBuilder delete(int start, int end) and deleteCharAt(int index) to remove a substring or a single character from a StringBuilder. package org.kodejava.lang; public class StringBuilderDelete { public static void main(String[] args) { StringBuilder lipsum = new StringBuilder("Lorem ipsum dolor sit " + "amet, consectetur adipisicing elit."); System.out.println("lipsum = […]
SERVLET / NOTES</>↗Servlet25 Jun 2007
package org.kodejava.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import javax.servlet.Servlet; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(urlPatterns = "/context-init-param") public class ContextInitParameter...
SERVLET / NOTES</>↗Servlet24 Jun 2007
package org.kodejava.servlet; 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 javax.servlet.http.HttpSession; import java.io.IOException; import java.io.PrintWriter; import java.util.Date; @WebServlet(name = "SessionLastAccessTime", urlPatterns = "/last-access-time") public class SessionLastAccessTime ext...
SERVLET / NOTES</>↗Servlet20 Jun 2007
Implementing the HttpSessionAttributeListener will make the servlet container inform you about session attribute changes. The notification is in a form of HttpSessionBindingEvent object. The getName() on this object tell the name of the attribute while the getValue() method tell about the value that was added, replaced or removed. package org.kodejava.servlet; import javax.servlet.annotation.WebListener; import javax.servlet.http.HttpSessionAttributeListener; import […]
SERVLET / NOTES</>↗Servlet19 Jun 2007
The Servlet specification define an HttpSessionListener interface that can be implemented if we want to listen to session creation and removal events. The interface has two methods that we can implement, the sessionCreated(HttpSessionEvent event) and sessionDestroyed(HttpSessionEvent event) methods. To activate the listener we need to register it in the servlet container. To register the listener […]