spring-logo

According to TLD, tag form:input must be empty, but is not

Problem Developing a search form with the Spring MVC framework. /WEB-INF/pages/tools/webserver.jsp – Spring mvc + form tag <form:form method="post" commandName="searchForm" action="${pageContext.request.contextPath}/tools/webserver/" class="navbar-form pull-left" id="search-form"> Type a website : <form:input path="domainName" type="text" width="165px" placeholder="example – google.com" /> <button type="submit" class="btn btn-top-margin">Search</button> </form:form> Spring Controller @Controller @RequestMapping(value = "/tools", method = RequestMethod.GET)Continue Reading

ascii-art-java

ASCII Art Java example

A funny Java example to create an ASCII art graphic. The concept is simple, get the image’s rgb color in “integer mode”, later, replace the color’s integer with ascii text. P.S This example is credit to this post and this post. ASCIIArt.java package com.mkyong;   import java.awt.Font; import java.awt.Graphics; importContinue Reading

java xml tutorials

How to count the depth of xml document (DOM example)

Note This question is from JNP forum, asking how to calculate the depth of the entire XML document. To get the depth of a XML, just loop the node recursively, and compare the level, that’s all.Here is a DOM parser example to count and show the deepest level of anContinue Reading

newrelic logo

New Relic for PHP, with cPanel + VPS

Here’s my journey to install “New Relic for PHP” to monitor my WordPress’s blog performance. Below is my server environment : Operating system CentOS 6.x 64-bit, VPS with root access cPanel 11.x Apache version 2.x PHP version 5.3.13 WordPress 3.5.1 P.S The New Relic is a web application performance tool.Continue Reading

spring-logo

Spring asm dependency issue in Spring Data

Using Spring Data MongoDB 1.2.1.RELEASE and Spring core 3.2.2.RELEASE, while system is starting, it hits some weird spring-asm IncompatibleClassChangeError errors : java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class pom.xml <properties>   <spring.version>3.2.2.RELEASE</spring.version> <springdata.version>1.2.1.RELEASE</springdata.version>   </properties>   <dependencies>   <!– Spring Core –> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency>  Continue Reading

cvs-file

How to read and parse CSV file in Java

A comma-separated values (CSV) file is just a normal plain-text file, store data in column by column, and split it by a separator (e.g comma “,”). For example : US,United States MY,Malaysia In this tutorial, we show you how to read, parse and print out the values from a csvContinue Reading

world-country

Display a list of countries in Java

In this article, we show you how to use the Locale class to play around the list of countries. P.S Tested with JDK 1.6 1. List of Countries The Locale.getISOCountries() will return a list of all 2-letter country codes defined in ISO 3166. ListCountry.java package com.webmitta.model;   import java.util.Locale;  Continue Reading

mongoDB-logo

MongoDB import and export example

In this tutorial, we show you how to backup and restore MongoDB with the commands : mongoexport and mongoimport. 1. Backup database with mongoexport Few examples to show you how to use the mongoexport to back up the database. Review some of the common use options. $ mongoexport Export MongoDBContinue Reading

spring data save binary file

Spring Data MongoDB : Save binary file, GridFS example

In MongoDB, you can use GridFS to store binary files. In this tutorial, we show you how to use Spring Data’s GridFsTemplate to store / read image in / from MongoDB. 1. GridFS – Save example (Spring config in Annotation) Gat an image file and save it into MongoDB. SpringMongoConfig.javaContinue Reading

301-redirect

Java HttpURLConnection follow redirect example

The HttpURLConnection‘s follow redirect is just an indicator, in fact it won’t help you to do the “real” http redirection, you still need to handle it manually. URL obj = new URL(url); HttpURLConnection conn = (HttpURLConnection) obj.openConnection(); conn.setInstanceFollowRedirects(true); //you still need to handle redirect manully. HttpURLConnection.setFollowRedirects(true); 1. Java Http RedirectContinue Reading

mac logo

Download JDK Source code for Mac OS X

The JDK source code is packaged in a src.jar, and should be in the JDK/Home folder. However, some JDK versions in Mac OSX didn’t include the source code or Javadoc. Try find it : sudo find / -name src.jar If you couldn’t find the src.jar, then get it from AppleContinue Reading

java_logo_100

How to get Http Response Header in Java

This example shows you how to get the Http response header values in Java. 1. Get response header from url “mkyong.com” URL obj = new URL("http://mkyong.com"); URLConnection conn = obj.openConnection(); Map<String, List<String>> map = conn.getHeaderFields(); 2. Get key’s (“Server”) value from the headers. Map<String, List<String>> map = conn.getHeaderFields(); List<String> serverContinue Reading

mongoDB-logo

MongoDB Authentication example

This guide shows you how to enable authentication in MongoDB. The authentication is disabled by default. To configure it, you must first add a user to the “admin” database. > show dbs admin #add single user to this database testdb Note Users with normal access in “admin” database, HAVE readContinue Reading

mongoDB-logo

MongoDB : couldn’t open /data/db/yourdb.ns errno:13 Permission denied

Starting MongoDB server, it shows error “Permission denied” on one of the database and shutdown the server automatically. $ mongod Fri Mar 8 22:54:46 [initandlisten] MongoDB starting : pid=13492 port=27017 dbpath=/data/db/ 64-bit host=Yongs-MacBook-Air.local //… Fri Mar 8 22:54:46 [initandlisten] journal dir=/data/db/journal Fri Mar 8 22:54:46 [initandlisten] recover : no journalContinue Reading

mongoDB-logo

How to install MongoDB on Mac OS X

A guide to show you how to install MongoDB on Mac OS X. MongoDB 2.2.3 Mac OS X 10.8.2 1. Download MongoDB Get MongoDB from official website, extracts it : $ cd ~/Download $ tar xzf mongodb-osx-x86_64-2.2.3.tgz $ sudo mv mongodb-osx-x86_64-2.2.3 /usr/local/mongodb 2. MongoDB Data By default, MongoDB write/store dataContinue Reading

Page 1 of 8812345...102030...Last »