User Login

Please enter user name and password into following boxes!

If you are not registered yet, please click

Forget Password

If you forget your password, please click

java-advanced

  • AspectJ Load Time Weaving in Spring

    Aspect-Oriented Programming (AOP) complements Object-Oriented Programming (OOP) by providing another way of thinking about program structure. The key unit of modularity in OOP is the class, whereas in AOP the unit of modularity is the aspect. Aspects enable the modularization of concerns such as transaction management that cut across multiple types and objects. (Such concerns are often termed crosscutting concerns in AOP literature.) Lets start how to configure load time weaving in Spring framework. applicationContext.xml Configuration <bean id=...Continue Reading

    How to use Custom Captcha and Authentication Manager in Spring Security

    Spring Configuration <http auto-config="false" use-expressions="true" entry-point-ref="loginUrlAuthenticationEntryPoint"> <intercept-url pattern="/index" access="permitAll"/> <intercept-url pattern="/kayit" access="permitAll"/> <intercept-url pattern="/sifre-hatirlatma" access="permitAll"/> <intercept-url pattern="/checkUser" access="permitAll"/> <intercept-url pattern="favicon.ico" access="permitAll"/> <intercept-url pattern="/kullanici/**" access="hasAnyAuthority('ROLE_ADMIN','ROLE_OFFICER','ROLE_CLIE...Continue Reading

    Hibernate Password Encryption with Jasypt in Spring MVC

    Create Password After downloaded Jasypt CLI Tools, execute following code by using encrypt.sh for linux based OS, or encrypt.bat file for Windows located in bin folder: encrypt.bat input="secret" password=encryptorpassword algorithm=PBEWithMD5AndTripleDES Output looks like this: AdK2HjMDfxTABg9ZP3kXSWsKo3t4rSn7 Note: Whenever run above command in command prompt, you will get different password each time because PBEWithMD5AndTripleDES algorithm and many other algorithms use random salt generator. For more information please click Add Maven Depe...Continue Reading

    Java Copy Fields From One Object to Another Object with Reflection

    Using Java Reflection, we can copy fields from one object to another object by using below class: public class FieldCopyUtil { public static void setFields(Object from, Object to) { Field[] fields = from.getClass().getDeclaredFields(); for (Field field : fields) { try { Field fieldFrom = from.getClass().getDeclaredField(field.getName()); Object value = fieldFrom.get(from); to.getClass().getDeclaredField(field.getName()).set(to, value); } catch (IllegalAccessExc...Continue Reading

    Spring MVC Internationalization (i18n) and Localization (L10n) Example

    Internationalization (i18n) or localization (L10n) is used to change language of a web application for better interaction. In this article, I will try to configure Spring MVC web application to use the Internationalization concept. Spring MVC Configuration Steps 1. mvc-dispatcher-servlet.xml file <mvc:interceptors> <!-- Changes the locale when a 'lang' request parameter is sent; e.g. /?lang=tr --> <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> <property name="para...Continue Reading

    Hibernate Many to Many Relationship to Save only Association in Join Table

    If we want to save or update only association table, we shouldn't use cascade in @JoinTable annotation. UserGroup Table @Entity public class UserGroup { @Id @GeneratedValue(strategy = GenerationType.AUTO) private int userGroupId; @Size(min = 4, max = 20, groups = SizeConstraintGroup.class) @Column(length = 20) private String name; @ManyToMany(fetch = FetchType.LAZY) @JsonIgnore @JoinTable( name = "UserGroup_User", joinColumns = @JoinColumn(name = "userGroupId", nullable = false, updatable...Continue Reading

    Spring MVC Return Previous Page After Successfull Login

    <!-- enable use-expressions -->

    <http auto-config="true" use-expressions="true">

    <!-- src** matches: src/bar.c src/baz.c src/test/bartest.c-->

    <intercept-url pattern="/problemSolution/home/**" access="hasRole('ROLE_ADMIN')"/>

    <intercept-url pattern="favicon.ico" access="permitAll"/>

    <form-login

    authentication-success-handler-ref="authenticationSuccessHandler"...Continue Reading

    Hibernate ManyToMany Save, SaveOrUpdate And Delete Operations

    In Hibernate ManyToMany relationship, save or saveOrUpdate operations must be as follows: User Entity @ManyToMany(fetch = FetchType.LAZY,cascade = CascadeType.ALL) @JoinTable( name = "UserRole_User", joinColumns = @JoinColumn(name = "userId", nullable = false, updatable = false), inverseJoinColumns = @JoinColumn(name = "userRoleId", nullable = false, updatable = false) ) private List userRoleList=new ArrayList(); In Line 1, cascade provides that when user is saved, an insert operation will be executed on UserRol...Continue Reading