Author
Please rectify my syntax error in jsp
sumanta panda
Ranch Hand
Joined: Jun 23, 2008
Posts: 224
Dear All,Please rectify my code so that i should not face the syntax error. <% int cmp = 0;int cmp_temp=0;int total=0; if(session.getValue("abc")!=null) { BankLog.l("iNoOfRec : "+iNoOfRec); for(int iCount=0;iCount < iNoOfRec;iCount++ ) { cmp_temp=Integer.parseInt((String )inVec.elementAt(3)); cmp=cmp+cmp_temp; } total=cmp+session.getValue("abc"); session.putValue("abc",total); } else { session.putValue("abc",0); } %>
aswin kumar
Greenhorn
Joined: Dec 25, 2008
Posts: 12
hi, just check these, int cmp = 0;int cmp_temp=0;int total=0; total is also changed again to zero because it is now in method scope so ,according to your requirement declare as a variable in class level scope, like <%!int total=0%>, hope it is useful for you, regards
sumanta panda
Ranch Hand
Joined: Jun 23, 2008
Posts: 224
Dear Aswini Sir, My doubt is how i write the same code example <% if {%>. Actually i am begineer .Hp you must rectify my code. Thanks and Regards Sumanta <% int cmp = 0;int cmp_temp=0;int total=0; if(session.getValue("abc")!=null) { BankLog.l("iNoOfRec : "+iNoOfRec); for(int iCount=0;iCount < iNoOfRec;iCount++ ) { cmp_temp=Integer.parseInt((String)inVec.elementAt(3)); cmp=cmp+cmp_temp; } total=cmp+session.getValue("abc"); session.putValue("abc",total); } else { session.putValue("abc",0); } %>
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35446
posted Dec 29, 2008 06:00:00
0
You didn't tell us what the error is that you're getting. Post the complete stack trace (you may have to look at the server's log files to see it).
you must rectify my code.
That doesn't sound like a really nice way of asking for help. You may want to get in the habit of using more polite language.
Android apps – ImageJ plugins – Java web charts
sumanta panda
Ranch Hand
Joined: Jun 23, 2008
Posts: 224
Sorry Sir,Please forgive me if i am wrong. Thanks and Regards Sumanta
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
My suggestion would be to learn good practices right off the bat and not put any Java code in your JSPs.
[Smart Questions ] [JSP FAQ ] [Books by Bear ] [Bear's FrontMan ] [About Bear ]
subject: Please rectify my syntax error in jsp