Posts

Showing posts from June, 2013

Change timezone in EC2 instance

Change time Timezone Check the time of the ec2 instance by > date. Normally it has 14 hours difference cat /etc/sysconfig/clock ZONE="UTC" UTC=true cp /etc/localtime /etc/localtime.backup ln -sf /usr/share/zoneinfo/Australia/Sydney /etc/localtime Make the change permanent by adding the following line to the "/etc/sysconfig/clock" file:  ZONE="Australia/Sydney" After this this will show the correct Sydney time

Spring Interceptors

applicationContext-dispatcher.xml we can configure the interceptors as follows in this. < bean id = "visitedPageInterceptor" class = "au.com.vvv.oes.ui.controller.interceptor.VisitedPageInterceptor" /> < bean id = "trailingSlashInterceptor" class = "au.com.vvv.oes.ui.controller.interceptor.TrailingSlashInterceptor" /> < bean id = "breadcrumbInterceptor" class = "au.com.vvv.oes.ui.controller.interceptor.BreadcrumbInterceptor" /> < bean id = "ie6Interceptor" class = "au.com.vvv.oes.ui.controller.interceptor.IE6Interceptor" /> < bean id = "SEOInterceptor" class = "au.com.vvv.oes.ui.controller.interceptor.SEOInterceptor" /> These interceptors can be post interceptors or preinterceptors. example visitedPageInterceptor will be as follows, package au.com.vvv.oes.ui.controller.interceptor; public class VisitedPag...

How to Define a Property in xml files and use it in JSP

Files To Modify :  build.xml / env.properties /a_config.xml / main.jsp ServiceLocator.xml - has some stuff build.xml ---------------------------------- <filter token="omniture.sCodeJsFile" value="${omniture.sCodeJsFile}"/> env.properties ---------------------------------- omniture.sCodeJsFile=s_code_dev.js aldous_css_oes_config.xml ----------------------------------  <omniture>   <sCodeJsFile>@omniture.sCodeJsFile@</sCodeJsFile>  </omniture> main.jsp ---------------------------------- <script type="text/javascript" src="${pageContext.servletContext.contextPath}/javascript/<tag:xmlConfigProperty key="omniture.sCodeJsFile"/>?@js_css.version@"></script>  <%@ taglib prefix="tag" tagdir="/WEB-INF/tags" %> ServiceLocator.xml ----------------------------------  <bean id="xmlConfiguration" class="org.apache.commons.configu...

Session State – it’s not complicated, but options are limited

Web apps have numerous choices for storing stateful data in between requests. For example, when a user goes through a multi-step wizard, he or she might make choices on page one that need to be propagated to page three. That data could be stored in http session. (It also could get stored into some backend persistence and skip session altogether). So where does session get stored? There are basically four choices here. Store state on one app serve r, i.e. for java in HttpSession. Subsequent requests need to be pinned to that particular app server via your load balancer. If you hit another app server, you will not have that data in session. Store state in session , and then replicate that session to all or many other app servers. This means you don’t need a load balancer to anchor a user to one app server; multiple requests can either hit any app server (full replication). Or use the load balancer to pin to particular cluster (themselves replicating sessions, and giving higher avail...

Optimistic Locking in Hibernate and JPA

When writing applications that are going to be accessed by more than one user at a time, you run the risk of the underlying data being corrupted. One solution to this problem is to implement row locks on the data being modified. However, should a process or a user be modifying several rows, this lock can lead to performance degradation as the DB begins to wait for locks to be released. A better solution is to use Optimistic Locking. This is where we monitor the row being modified and allow other users to access it. No lock is being applied here. However, once the row has been saved back to the database, all the rows that are still being viewed become out-of-date, or stale. The simplest method by which the row can be monitored is to employ a “version” column. This is a simple counter that increments every time an update is performed on the row. In JPA annotations this is represented by the @Version annotation. @Version @Column(name = "version", nullable = false, leng...