aspose file tools*
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem as stack over flow" Watch "problem as stack over flow" New topic
Author

problem as stack over flow

Shyam Sunder
Greenhorn

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"};



try{

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(sb.length());

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

alMonthYear.size();

alMonthYear.add(sb);

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));

}

}

}reportForm.setAlMonths(alMonthYear);

}



catch (Exception e) {

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

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

e.printStackTrace();

}

return mapping.findForward("success");



}
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30973
    
159

Shyam,
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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Shyam,

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.


Merrill
Consultant, Sima Solutions
 
Consider Paul's rocket mass heater.
 
subject: problem as stack over flow