Bala Tilak

Ranch Hand
+ Follow
since Oct 07, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bala Tilak

Thanks for the reply. Yes , as per my research on Internet also , I think, caching frequently accessed data (which dont change often ) from DB is a better choice. So we can avoid DB access for this data.

Now the question is , lets say I have a set of records, the lottery results of a state which change once in a day. I cached these results in Java (as there are 1000s of page requests for the same results on my website.). Is there any Pattern/algorithm to manage this cached data to automatically refresh when the corresponding records updated in DB ?. I am maintaining last updated column in DB for each of this lottery entry. Either programatically or using existing Cache framework in Java.

1 week ago
Hi All,

I have a java web application. My application uses Struts2. My application generates the results of games (each state page have around 10 games and the results are published twice daily for 7 games and two are weekly).

Now I dont want to generate the same html (from JSP everytime) instead I want to Cache the generated HTML page (like PHP Caching) and only generate the new page when ever there is a change in the states data..

Is there any tool like QuickCache for PHP available for Java ?

Or Do I need to program it manually, If yes, can you suggest me the best method to implement this.

Thanks in advance,
2 weeks ago

${pageContext.request.contextPath} gives the webApp context. So this solved the issue for both Development environment as well as production. Thank you.


1 month ago
Hi All,

I have a web application in Struts 2. It has common main menu and footer.. so I extracted the common stuff into JSP fragments and including them on different pages..

Not the issue is on of the JSP fragment is Main Menu at top bar. The urls i have given relative paths..its working fine with the first level urls.. like mydomain/home, mydomain/firstpage

but for the second level.. mydomain/inside/innerpage in this case the links on included jsp fragment are not working properly as I have given relative paths..

Is there any option or Do I have to go with absolute urls.. Its hard to maintain with absolute urls when I am testing in localhost..
1 month ago
Thank you Tim Moores.

Geolite2 database is good for my purpose. Thanks a lot for quick response.

2 months ago
Hi All,

I have a web application written in Struts 2.0. As part of requirements I need show affiliate links only for users of specific location like Florida US , and another link for UK and so.

How can I get the user location in Struts 2.0 web applicaiton.

thanks in advance.

2 months ago
Thanks for the suggestion Tim Moores.

i have gone through pebble.  Its in Spring and My current website is Struts2.0. Just thinking if its feasible ( in the terms of maintenance) if I combine both.

Or Should I have a separate application for Blog and have a sub domain (which is not recommended  by SEO experts)

Or I should write my own Simple Template Engine in the existing application in Struts2 similar to Pebble by copying the Pebble patterns . As I dont need any fancy features like user management, comments section .. I think this would be possible way to go.

Please weigh in ..
10 months ago
Hi All,

I have a website running on Tomcat and using Struts2.0 with Mysql as DB.

The website displays the latest scores of the sports. As part of SEO I wanted to start a blog for my website. Something like

Can you suggest any simple framework that can plug in to Struts 2.0 so I can have blog features in my site. I thought of Apache Roller , but its too heavy for me as my site is not a standalone blog with multi user support and other features. I just want a simple blog where I am the only contributor and no comments or user management is required for me.

If such simple framework is not available, Please suggest me some simple architecture to handle blog requirement like where store data..

Thanks in advance.
10 months ago

byte[] bytes = /* something */;
String correspondingString = new String(bytes);

Got it now. So BLOB should be a byte[] in Java, not the String. So either I have to go for CLOB mapped to String in Java, or Go for BLOB and mapped it to byte[] in Java.

MySQL  -- Java

BLOB --> byte[]
CLOB --> String.

Thanks you all. I can't update the DB now , so I have changed the filed to byte[] in Java mapping file and then converting it to String using new String(byte[]) after reading from DB.

I have been using Java and Hibernate for DAO. I stored a long text in on of the field which is MySQL blob and inserted the record in DB using MYSQL Query Browser. When I run select query it showing the string ok.

But When I read it in Java application and trying to show on JSP its been shown as [B@da99836. or some similar value. I debugged the application if its JSP issue.. even in Java application also its been read as same junk value.

Can someone help me with this.. Thanks in Advance.
Hi All,

I have a Java web application deployed in Amazon EC2 windows server. As it was a test application I selected the free tier EC2 machine, with 1 GB RAM with 1 CPU core.

After a couple of years hard work, the traffic to my website has been increased and now its slowing down and sometimes its taking more than 60 seconds to respond . After looking the java layer taking more time which used to be micro seconds.. There is no much change in the logic its the same Action classes with simple processing and fetching the data from DB.

I also observed that common daemon service runner is taking 90% of the Memory. So I am just thinking of improve the performance.. please guide me how to proceed.

Below are the various options I wish to try

1. Changing the EC2 instance type, should I opt for More RAM ( lets say 2 GB) or should I opt for more Cores. If I go for more Cores should I change the code to better use multi core CPU ?

2. Also to understand if I can better tune the code how can I start analyzing the code ( Heap Dump or Thread Dump) ? Should I take the heap Dump from the Production server and analyze ?
1 year ago
Just refreshing my generics understanding....

Is below declarations are same..

public static void someMethod(List<?> someList) {


public static void someMethod(List<Object> someList) {

If not whats the difference..
1 year ago
I have a contact us form on the application and is mapped to a Struts2 Action. It was working fine until, I changed the server and deployed the Tomcat behind Apache2. The action class not setting the request parameters and empty strings are being stored in DB. Its working fine if user the GET on the form .. and in local machine where I run the code in eclipse and tomcat plug in.. both GET and POST are working fine.. where as in Production only GET are setting the request parameter values to Action class attribute but POST setting the emtpy/null values. Is it due to introducing the apache server ?? Or Did I change something accidentally ??
1 year ago
Hi All,
Thanks for your support. I have a design question..

As part of my application, I have to implement a group of algorithms.. where the task is common . each algorithm takes a set of arguments lets say Date, 2 input numbers and it returns list of numbers. typically as below

public static List<Integer> generateNumbers( Date startingDate, Integer startNum, Integer endNum) {
// bla bla bla

I have to implment different algorithms and want to choose an algorithm at run time... I can't place all the algorithms in a single class (one method for each algorithm) as there can be 20 to 30 algorithms. Want to have a  dedicated class for each algorithm. Please note that these algorithms purely based on input values ( means does not have any state) so I dont want to instantiate the class.. I better choose to have each class have a static method ..

The basic strategy pattern ( what ever I read in books) have defined a super interface DefaultGenerator have a method generateNumbers and have different classes implementing this interface like.. QuickGenerator, SequentialGenerator and so on. And get the class isntance based on required algorithm and invoke generateNumbers method. Is there any alternate pattern to avoid instantiating the classes and define the algorithm in static method ?

2 years ago