Tallan's Technology Blog

Tallan's Top Technologists Share Their Thoughts on Today's Technology Challenges

Posts Tagged "Enterprise Java"

Parsing HTML using jsoup library

Richard Krajunus

A quick tutorial on html parsing using the jsoup Java library.

Java EE 6 Overview

Dylan Barrett

Introduction
For the past year or so I have been working on a web development project using Java.  Like many Java projects, the project I was working on used 3rd party frameworks like Spring and Hibernate rather than utilizing the official Java EE stack.  Many developers have turned to these frameworks because the official Java EE stack had been notoriously cumbersome and difficult to use.  That is starting to change.  Java EE 5 started moving Java EE in a new direction.  Inspired by the ideologies of the 3rd party frameworks, the JCP, the standards community that works on the Java specification, began to make radical changes to the core of Java EE.  These changes have continued in the latest iteration, Java EE 6.
Interested in comparing Java EE 6 to my experiences with Spring and Hibernate, I picked up a book on…

The Unstandard Tag Library: Using Constants Within JSPs

Dylan Barrett

Introduction
The Unstandard Tag Library is a JSP tag library that was developed as part of the Jakarta Project. Its purpose is to provide a collection of useful tags that people have been requesting for JSTL. The library serves as a place to keep all of these tags until they are officially added to the Standard Tag Library. This article focuses on the use of one of the tags contained within the library, the useConstants tag.
The Problem
While working on a project for a client, I realized that they were using a Java class with constants to define strings used within the application. The idea was to use the constants everywhere in the application where the strings were needed so they could easily be maintained in one location without having to search through the whole application when making a change. This makes…

Pass by reference

In C++ and C#, developers have freedom to modify variables by directly having access to memory location.
In C++,
#include <stdio.h>
void swapnum(int &i, int &j) {
int temp = i;
i = j;
j = temp;
}
int main(void) {
int a = 10;
int b = 20;
swapnum(a, b);
printf(“A is %d and B is %d\n”, a, b);
return 0;
}
In C#,
int a = 1;
modify(ref a); //now a=2
void modify(ref int a)
{
a = 2;
}
In Java, however, there’s no such thing as pass by reference.  Even the so-called pointers (created by ‘new’ operator) are passed by copy of the reference.
Thus, if you do the following,
String a = “a”;
modify(a); //a doesn’t change, since a is being passed as a copy of the pointer a.
void modify(String a)
{
a = “b” //this a is a different pointer, thus does not affect the real ‘a’ pointer outside of the method.
}
As you can see, there’s no direct way of modifying…

Cache as a cross-cutting concern

I have been recently asked to look into the cache feature within Springmodule in Java community.
Since my current project utilizes spring and aop, I thought it would be a great idea to utilize AOP to cache data.
I actually wrote a prototype file and it was a very rudimentary yet working prototype.  However, I soon realized that Springmodules already created such feature, and it toally is a great feature to use.
Using simple AOP concept, you intercept the method call and using method parameters as HashKeyGenerator input values, the Springmodules’s cache simply get/put data from/into cache storage.  Currently, I configured it to using OSCache for its native support by Springmodule Cache Provider.
https://springmodules.dev.java.net/docs/reference/0.8/html/cache.html
I believe as the frameworks such as Spring evolves, developers can truly focus on their logic and development without worries of logging, security, cache, and any other cross-cutting concerns.  AOP is…

Hibernate: Merge vs SaveOrUpdate

In my previous and current project, I have run into cases where I needed to save an object to database using hibernate, and from time to time, I run into some sort of Hibernate Session Exception.
I did a bit of google search, and it turns out that when saving an object, I needed to make sure the object was attached to Hibernate session.
This can be very tedious issue, since that means if you need to save an object that is not attached to a session, you need to do these.

Retrieve the object using the Id value found within the object passed to you.
Update the property values one by one
Save the object back within the same Hibernate Session

Here’s a quick summary that I found out about MERGE and SaveOrUpdate.
void saveOrUpdate(object)->object must be attached to a hibernate session (including all sub objects…

\\\