SERVLET / CATATAN</>↗Servlet07 Feb 2007
When creating a servlet we can use the @WebInitParam to define some init parameters in the servlet configuration section (@WebServlet). This init parameter can be used to define where a configuration file of our application is stored, define upload path, etc. This simple servlet below shows how to obtain these init parameters value. package org.kodejava.servlet; […]
SERVLET / CATATAN</>↗Servlet04 Feb 2007
package org.kodejava.servlet; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.Cookie; 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 = "ReadCookieServlet", urlPatterns = "/read-cookie") public class ReadCookieExample extends HttpServlet { @Override protected vo...
JDBC / CATATAN</>↗JDBC03 Feb 2007
package org.kodejava.jdbc; import java.sql.*; public class GetGeneratedKeyExample { private static final String URL = "jdbc:mysql://localhost/kodejava"; private static final String USERNAME = "kodejava"; private static final String PASSWORD = "s3cr*t"; public static void main(String[] args) { try (Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD)) { // The orders table have an ID column which value will be […]
JDBC / CATATAN</>↗JDBC02 Feb 2007
Executing a database manipulation command such as insert, update or delete can sometime throw exception due to invalid data. To protect the integrity of our application data we must make sure that when a transaction fails we must rollback all the executed queries. In this example we are using MySQL database. To enable transaction capability […]
SERVLET / CATATAN</>↗Servlet31 Jan 2007
A cookie is a piece of information sent to a browser by a Web Server. The browser then returns that information to the Web server. This is how some Web pages remember your previous visits; for example, an e-commerce website might use a cookie to remember which items you’ve placed in your online shopping cart. […]
JDBC / CATATAN</>↗JDBC27 Jan 2007
The following example show you how to create a connection to Microsoft Access databases. To allow the database access to be authenticated, the security user account can be added from File -> Info -> Users and Permissions screen. Just like accessing any other databases in the Java platform we need a JDBC driver. To access […]