SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

CORE API / NOTES</>↗
Core API28 Sep 2008

How do I get the path from where a class is loaded?

This examples shows how to get a path name or location from where our class is loaded. package org.kodejava.lang; public class CodeSourceLocation { public static void main(String[] args) { CodeSourceLocation csl = new CodeSourceLocation(); csl.getCodeSourceLocation(); } private void getCodeSourceLocation() { // The location from where the class is loaded. System.out.println("Code source location: " + getClass().getProtectionDomain().getCodeSource().getLocation()); […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API25 Sep 2008

How do I validate email address using regular expression?

In this example we use the String‘s class matches() methods to match a string to be a valid email address based on the given regex. This example also demonstrate the power of regular expression to validate an email address. Using regular expression makes it easier to validate data such as email address. After the code […]

Wayan · 2 min read
JSP / NOTES</>↗
JSP24 Sep 2008

How do I include a page fragment into JSP?

In this example you can learn how to include a JSP fragment into another JSP page. This is a common practice when creating a web application where we usually have a navigation section, the main content and the footer of a web page. Using the include directive make it simpler to maintain the fragment of […]

Wayan · 2 min read
SERVLET / NOTES</>↗
Servlet22 Sep 2008

How do I define welcome files for web application?

The configuration below gives us example how to define a welcome-files to our web application. The welcome file is default file to be loaded by a servlet container when we access a URL without telling which page to load. <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <welcome-file-list> <welcome-fi...

Wayan · 1 min read
CORE API / NOTES</>↗
Core API18 Sep 2008

How do I search collection elements?

This code example use the Collections.binarySearch() to search an specified object inside a specified collections. Prior to calling the binarySearch() method we need to sort the elements of the collection. If the object is not sorted according to their natural order the search result will be undefined. package org.kodejava.util; import java.util.Arrays; import java.util.LinkedList; import java.util.Collections; […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API15 Sep 2008

How do I rotate elements of a collection?

This example demonstrate how to rotate the elements of a collection object. We can use the java.util.Collections class and call the rotate() method with the collection to rotate and the distance as the parameters. package org.kodejava.util; import java.util.List; import java.util.ArrayList; import java.util.Collections; import java.util.Arrays; public class CollectionRotate { public static void main(String[] args) { List<Integer> […]

Wayan · 1 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.