The moose likes Struts and the fly likes problem as stack over flow Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem as stack over flow" Watch "problem as stack over flow" New topic

problem as stack over flow

Shyam Sunder

Joined: Dec 23, 2006
Posts: 24
public ActionForward getMonthYear(

ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response) {

GenerateReportBD reportBD = null;

GenerateReportVO reportVO = null;

GenerateReportForm reportForm = null;

ArrayList alMonthYear = null;

// Iterator iter = null;

// HashMap hmData = null;

String reportType = null;

String strClientId = null;

String months = null;

String []Month = new String[]{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};


alMonthYear = new ArrayList();

System.out.println("inside GetMonth");

Calendar cal = Calendar.getInstance();

System.out.println("after calender GetMonth");

String month = Month[cal.get(Calendar.MONTH)];

System.out.println("after Month"+month);

int Year = cal.get(Calendar.YEAR);

System.out.println("after cal.get");

for(int i=0; i<12;i++)


System.out.println("inside for loop");

if(Month[i].equals(month) )


for(int j=i;j>=0;j--)

{ StringBuffer sb = new StringBuffer();

String str = Month[j-1];

sb.append(str).append(" ").append(Year);





System.out.println(alMonthYear.size()); //System.out.println(" +++++++" +alMonthYear.get(i));


for(int k=11;k>i;k--)


String str1 = Month[k];

// StringBuffer sb1 = new StringBuffer();

// sb.append(str1).append(" ").append(Year-1);

// System.out.println(""+sb);

System.out.println(Month[k]+" "+(Year-1));





catch (Exception e) {

// SDALogger.logError( this,"SDAException in CheckListDispatchAction@createCheckList()",e);

// System.out.println("Exception in GenerateReportAction submit ................"+e);



return mapping.findForward("success");

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32815

A stack overflow usually means an infinite loop or code that calls itself. Once in a while, it means you are just using too much memory. It's good practice to rule out the common causes before looking at the memory. And you aren't doing anything memory intensive.

Try simplifying the code to see if the error still occurs. For example, what happens if you comment out the loop with index "k". If the problem still occurs, you can comment out more code. If not, you know where to examine more closely.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864

When you post java code and want us to look at it, we'll all thank you if you enclose the code in [ c o d e ] [ / c o d e ] tags (without the spaces). This will preserve the indents in your code and make it infinitely easier to read.

Consultant, Sima Solutions
Consider Paul's rocket mass heater.
subject: problem as stack over flow
It's not a secret anymore!