SupportWriter space ↗
A JOURNAL ABOUT TECHNOLOGY

Learn something new.
Write. Share.

A space to connect knowledge, one line of code a day.
Discover tutorials, ideas, and notes from a learning journey.

1967 notes & counting ↙
EDITOR’S PICK ↗
Pentesting

Planning Your First Web Application Pentest: Scope, Safety, and Evidence

Build a focused web pentest plan with clear authorization, realistic objectives, controlled testing, and evidence that developers can use.

D Putu Adi Guna Permana · 3 min read
FOR YOUR CURIOSITY

Latest notes.

SERVLET / NOTES</>↗
Servlet20 Jun 2007

How do I get a notification when session attribute was changed?

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 […]

Wayan · 2 min read
SERVLET / NOTES</>↗
Servlet19 Jun 2007

How do I capture session creation and removal events?

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 […]

Wayan · 2 min read
SERVLET / NOTES</>↗
Servlet16 Jun 2007

How do I invalidate user’s session?

In a web application you might want to invalidate user session, for instance in a logout Servlet or JSP. There is an invalidate() method in the HttpSession interface, this method invalidates the session, and it removes all attributes from the session object. 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.ht...

Wayan · 2 min read
SERVLET / NOTES</>↗
Servlet13 Jun 2007

How do I get client IP and hostname in Servlet?

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 java.io.IOException; import java.io.PrintWriter; @WebServlet(name = "ClientAddressServlet", urlPatterns = "/client-ip") public class ClientAddressServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest r...

Wayan · 1 min read
CORE API / NOTES</>↗
Core API12 Jun 2007

How do I convert time between timezone?

package org.kodejava.util; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; public class TimeZoneExample { public static void main(String[] args) { // Create a calendar object and set it time based on the local // time zone Calendar localTime = Calendar.getInstance(); localTime.set(Calendar.HOUR, 17); localTime.set(Calendar.MINUTE, 15); localTime.set(Calendar.SECOND, 20); int hour = localTime.get(Calendar.HOUR); int minute = localTime....

Wayan · 1 min read
CORE API / NOTES</>↗
Core API09 Jun 2007

How do I set default Locale?

package org.kodejava.util; import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.Random; public class DefaultLocaleExample { public static void main(String[] args) { // Use Random class to generate some random number Random random = new Random(); // We use the system default locale to format a number and a date. NumberFormat formatter = […]

Wayan · 2 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.