I know that I know nothing

jsoup: Java HTML Parser like jquery

clock May 2, 2015 19:01 by author Administrator

jsoup is a Java library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods.


String userURL = "";

content of this request contain this tag


<input type="text" id="txt_title" value="title"  />
Document doc = Jsoup.connect(userURL).get();



What's the difference between <%@ include file="header.html" %> and <jsp:include page="header.jsp" />

clock April 9, 2015 21:18 by author Administrator



1) The include directive: <%@ include file="header.html" %>

Static: adds the content from the value of the file attribute to the current page at translation time. The directive was originally intended for static layout templates, like HTML headers.
2) The <jsp:include> standard action <jsp:include page="header.jsp" />

Dynamic: adds the content from the value of the page attribute to the current page at request time. Was intended more for dynamic content coming from JSPs.
3) The <c:import> JSTL tag: <c:import url=”” />

Dynamic: adds the content from the value of the URL attribute to the current page, at request time. It works a lot like <jsp:include>, but it’s more powerful and flexible: unlike the other two includes, the <c:import> url can be from outside the web Container!


ref :


get Locale in java

clock April 9, 2015 20:24 by author Administrator



create custom dependency in maven

clock April 9, 2015 18:33 by author Administrator

mvn install:install-file -Dfile=/azizkhani/font.jar -DgroupId=org.roshan  -DartifactId=font -Dversion=1 -Dpackaging=jar

Getting full string stack trace including inner exception

clock March 22, 2015 21:46 by author Administrator

public static String joinStackTrace(Throwable e) {
        StringWriter writer = null;
        try {
            writer = new StringWriter();
            joinStackTrace(e, writer);
            return writer.toString();
        } finally {
            if (writer != null)
                try {
                } catch (IOException e1) {
                    // ignore

    public static void joinStackTrace(Throwable e, StringWriter writer) {
        PrintWriter printer = null;
        try {
            printer = new PrintWriter(writer);

            while (e != null) {

                StackTraceElement[] trace = e.getStackTrace();
                for (int i = 0; i < trace.length; i++)
                    printer.println("\tat " + trace[i]);

                e = e.getCause();
                if (e != null)
                    printer.println("Caused by:\r\n");
        } finally {
            if (printer != null)

Use Spring JavaMailSender and Freemarker to send Email by template

clock March 18, 2015 19:32 by author Administrator


<bean class="org.springframework.mail.javamail.JavaMailSenderImpl" id="mailSender">
  <property name="host" value="${}"></property>
  <property name="username" value="${mail.username}"></property>
  <property name="password" value="${mail.password}"></property>
  <property name="javaMailProperties">
      <prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
      <prop key="mail.smtp.port">${mail.smtp.port}</prop>
      <prop key="">${}</prop>
      <prop key="mail.smtp.starttls.enable">true</prop>


<bean class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean" id="freemarkerConfiguration">
  <property name="preferFileSystemAccess" value="false"></property>
  <property name="templateLoaderPath" value="classpath:/"></property>




import java.util.Map;
import javax.mail.internet.MimeMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.mail.javamail.MimeMessagePreparator;
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
import freemarker.template.Configuration;

public class MailService {
  private JavaMailSender javaMailSender;

  private Configuration freemarkerConfiguration;
  public void sendMail(final String from, final String to, final String subject, final Map<string object=""> model, final String template){
    MimeMessagePreparator preparator = new MimeMessagePreparator() {
           public void prepare(MimeMessage mimeMessage) throws Exception {
              MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
              message.setFrom(from, "azizkhani");
              //template sample: "freemarker/confirm-register.ftl"
                String text =FreeMarkerTemplateUtils.processTemplateIntoString(freemarkerConfiguration.getTemplate(template,"UTF-8"), model);
              message.setText(text, true);


freemarker template engine ------try catch if else loop

clock March 18, 2015 12:58 by author Administrator


i think one of best solution for generate code is using template engine like freemarker.
for using try catch or if else and some other expression in it using like this

attempt block

recover block

<#if x == 1> x is 1
<#elseif x == 2> x is 2
<#elseif x == 3> x is 3

<#list fields as field>

this template generate fileds for hibernate hbm.xml

<#list fields as field>
<#if "${field.type.superclass}"=="class org.model.BaseEntity">
<many-to-one name="${}" column="${}" entity-name="${}" not-null="true" />
<property column="${}" name="${}" type="${field.type.simpleName}" not-null="false" />
<property column="${}" name="${}" type="${field.type.simpleName}" not-null="false" />


How to determine and print jQuery version?

clock March 13, 2015 15:51 by author Administrator

Using HTML5 Geolocation to get current location

clock February 27, 2015 20:44 by author Administrator

 if(!!navigator.geolocation) {
                navigator.geolocation.getCurrentPosition(function(position) {
                    var geolocate = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

jump into interface implementation in Eclipse IDE

clock January 19, 2015 21:22 by author Administrator

here's a big productivity boost if you add an Alt + F3 key binding to the Open Implementation feature,

and just use F3 to go to interfaces, and Alt + F3 to go to implementations.

Open implementation keybinding




Press Ctrl + T on the method name (rather than F3)

About the author

 Welcome to this web site . This page has two purposes: Sharing information about my professional life such as articles, presentations, etc.
This website is also a place where I would like to share content I enjoy with the rest of the world. Feel free to take a look around, read my blog

Java,J2EE,Spring Framework,JQuery,

Hibernate,NoSql,Cloud,SOA,Rest WebService and Web Stack tech...


Month List

Sign In