CORE API / CATATAN</>↗Core API14 Des 2006
In the following example we want to get the date of the specified day-of-the-year. We can define a calendar for a specific day of the year by setting the java.util.Calendar object DAY_OF_YEAR field using the set() method. The method take the field to be set and a value. package org.kodejava.util; import java.util.Calendar; public class DayOfYearToDate […]
CORE API / CATATAN</>↗Core API11 Des 2006
package org.kodejava.jndi; import javax.naming.Context; import javax.naming.InitialContext; import javax.servlet.Servlet; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.sql.DataSource; import java.io.IOException; import java.io.PrintWriter; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import...
CORE API / CATATAN</>↗Core API07 Des 2006
A system properties named user.dir can be used if you want to find the current working directory of your Java program. package org.kodejava.io; public class CurrentDirectoryExample { public static void main(String[] args) { // System property key to get current working directory. String USER_DIR_KEY = "user.dir"; String currentDir = System.getProperty(USER_DIR_KEY); System.out.println("Working Directory: " + currentDir); […]
SERVLET / CATATAN</>↗Servlet06 Des 2006
ServletRequest or HttpServletRequest object has a map object that maps parameter name and its value. By accessing this map we can check if a parameter was passed in servlet request. Let’s see the example below. 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.IOExcepti...
SERVLET / CATATAN</>↗Servlet06 Des 2006
This example show you how to obtain parameter name from servlet request. By calling request.getParameterNames() you will get an Enumeration object by iterating this object you can get the parameter names. 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; im...
SERVLET / CATATAN</>↗Servlet03 Des 2006
When creating an application with Java servlet most of the time we will work with the request and response object. From the request object we can read the parameter submitted by the user’s browser either through an HTTP GET or POST method. Basically what you need to know is when you try to get the […]