• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please rectify my syntax error in jsp

 
sumanta panda
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sumanta panda
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Sir,Please forgive me if i am wrong.

Thanks and Regards
Sumanta
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My suggestion would be to learn good practices right off the bat and not put any Java code in your JSPs.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic