Help on Syntax error on token "catch" on JSP

general-dev
#1

Hello People,
I am receiving an error when I run my JSP. can someone help me with the jsp error. The jsp is as below. How can I solve this Problem? Please help

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="NetObjects Fusion 5.0 for Windows">
<TITLE>Payment Status</TITLE>

<%-- Standard taglib --%>
<%@ taglib uri="/jstl-c" prefix="c" %>
<%@ taglib uri="/jstl-fmt" prefix="fmt" %>
<%@ taglib uri="/jstl-sql" prefix="sql" %>
<%@ taglib uri="/string" prefix="str" %> 
<%--
<-%-@ page errorPage="/errorpage/errorpage.jsp" %->
--%>
<%--

Querying the database
--%>				   
>

				   

<%@ page import="org.asycuda.webservices.asybanks.client.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>

<jsp:useBean id="abcashier" class="org.asycuda.webservices.asybanks.client.AsyBanksCashierController" scope="session"/>



<LINK REL=STYLESHEET TYPE="text/css" HREF="../../../Income/Customs/Payment_Status/style.css">
<LINK REL=STYLESHEET TYPE="text/css" HREF="../../../Income/Customs/Payment_Status/site.css">
<STYLE>
</STYLE>
</HEAD>
<BODY LEFTMARGIN=0 MARGINWIDTH=0><br>
    <%
	String driver ="org.gjt.mm.mysql.Driver";
    String url = "jdbc:mysql://localhost:3306/asydb2";
     String username = "root";
     String password = "zambia";
	
	
	try
	
	{
	Class.forName(driver);
	 //Connection con = DriverManager.getConnection(url,username,password); 
	  Connection con = DriverManager.getConnection(url,username,password);
	  
	  System.out.println(con); 
	  
	 System.out.println("got connection"); 

  
  Statement s = con.createStatement(); 

  String sql = "SELECT number,amount,date,Type,year,serial,cuoCod,nber FROM sad_gen2"; 
  ResultSet rs = s.executeQuery(sql); 
  while (rs.next()) {
  
  
  //Connecting the Client web service
	String amount =rs.getString(2);
String type =rs.getString(4);
String year = rs.getString(5);
String serial =rs.getString(6);
String cuo_cod =rs.getString(7);
String nber =rs.getString(8);


ServiceResult serviceResult = abcashier.notifyCollection(year, cuo_cod, serial, nber, amount);
pageContext.setAttribute("serviceResult", serviceResult);


System.out.println(rs.getString(7) + " " + rs.getString(8));
System.out.println(rs.getString(7) + " " + rs.getString(8));
%>
    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=514 NOF=LY>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD WIDTH=5 HEIGHT=8><IMG SRC="../../../clearpixel.gif" WIDTH=5 HEIGHT=1 BORDER=0></TD>
            <TD></TD>
        </TR>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD HEIGHT=59></TD>
            <TD WIDTH=509><IMG ID="Banner1" HEIGHT=59 WIDTH=509 SRC="../../../Payment_Status_NBanner.GIF" BORDER=0 ALT="Payment Status"></TD>
        </TR>
    </TABLE>
    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=717 NOF=LY>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD WIDTH=56 HEIGHT=20><IMG SRC="../../../clearpixel.gif" WIDTH=56 HEIGHT=1 BORDER=0></TD>
            <TD WIDTH=661><IMG SRC="../../../clearpixel.gif" WIDTH=661 HEIGHT=1 BORDER=0></TD>
        </TR>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD></TD>
            <TD WIDTH=661 CLASS="TextObject"><c:if test="${serviceResult.code != 0}">
                <P><SPAN STYLE="font-size: medium;">Sorry, the system found this problem: <SPAN STYLE="color: rgb(255,0,0);"></SPAN> <c:out value="${serviceResult.message}"/></SPAN></P>
                </c:if></TD>
        </TR>
    </TABLE>
    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=759 NOF=LY>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD WIDTH=138 HEIGHT=1><IMG SRC="../../../clearpixel.gif" WIDTH=138 HEIGHT=1 BORDER=0></TD>
            <TD></TD>
        </TR>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD HEIGHT=307></TD>
            <TD WIDTH=621><c:if test="${serviceResult.code == 0}">
                <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=303 NOF="LayoutRegion1">
                    <TR VALIGN=TOP ALIGN=LEFT>
                        <TD WIDTH=303 HEIGHT=3><IMG SRC="../../../clearpixel.gif" WIDTH=303 HEIGHT=1 BORDER=0></TD>
                    </TR>
                    <TR VALIGN=TOP ALIGN=LEFT>
                        <TD WIDTH=303 CLASS="TextObject">
                            <P><SPAN STYLE="font-size: large;">Customs Registration Number</SPAN></P>
                        </TD>
                    </TR>
                </TABLE>
                <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 WIDTH=285 NOF="LayoutRegion1">
                    <TR VALIGN=TOP ALIGN=LEFT>
                        <TD>
                            <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=178 NOF="LayoutRegion1">
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD WIDTH=75 HEIGHT=30><IMG SRC="../../../clearpixel.gif" WIDTH=75 HEIGHT=1 BORDER=0></TD>
                                    <TD WIDTH=1><IMG SRC="../../../clearpixel.gif" WIDTH=1 HEIGHT=1 BORDER=0></TD>
                                    <TD WIDTH=50><IMG SRC="../../../clearpixel.gif" WIDTH=50 HEIGHT=1 BORDER=0></TD>
                                    <TD WIDTH=1><IMG SRC="../../../clearpixel.gif" WIDTH=1 HEIGHT=1 BORDER=0></TD>
                                    <TD WIDTH=51><IMG SRC="../../../clearpixel.gif" WIDTH=51 HEIGHT=1 BORDER=0></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD></TD>
                                    <TD COLSPAN=3 WIDTH=52 CLASS="TextObject">
                                        <P>Year</P>
                                    </TD>
                                    <TD></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=5 HEIGHT=6></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD></TD>
                                    <TD COLSPAN=4 WIDTH=103 CLASS="TextObject">
                                        <P>Customs Ofice</P>
                                    </TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=5 HEIGHT=11></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD></TD>
                                    <TD COLSPAN=2 WIDTH=51 CLASS="TextObject">
                                        <P>Serial</P>
                                    </TD>
                                    <TD COLSPAN=2></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=5 HEIGHT=12></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD></TD>
                                    <TD COLSPAN=2 WIDTH=51 CLASS="TextObject">
                                        <P>Number</P>
                                    </TD>
                                    <TD COLSPAN=2></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=5 HEIGHT=10></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=2></TD>
                                    <TD COLSPAN=2 WIDTH=51 CLASS="TextObject">
                                        <P>Amount</P>
                                    </TD>
                                    <TD></TD>
                                </TR>
                            </TABLE>
                        </TD>
                        <TD>
                            <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=107 NOF="LayoutRegion1">
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD WIDTH=37 HEIGHT=31><IMG SRC="../../../clearpixel.gif" WIDTH=37 HEIGHT=1 BORDER=0></TD>
                                    <TD WIDTH=1><IMG SRC="../../../clearpixel.gif" WIDTH=1 HEIGHT=1 BORDER=0></TD>
                                    <TD WIDTH=1><IMG SRC="../../../clearpixel.gif" WIDTH=1 HEIGHT=1 BORDER=0></TD>
                                    <TD WIDTH=1><IMG SRC="../../../clearpixel.gif" WIDTH=1 HEIGHT=1 BORDER=0></TD>
                                    <TD WIDTH=64><IMG SRC="../../../clearpixel.gif" WIDTH=64 HEIGHT=1 BORDER=0></TD>
                                    <TD WIDTH=1><IMG SRC="../../../clearpixel.gif" WIDTH=1 HEIGHT=1 BORDER=0></TD>
                                    <TD WIDTH=1><IMG SRC="../../../clearpixel.gif" WIDTH=1 HEIGHT=1 BORDER=0></TD>
                                    <TD WIDTH=1><IMG SRC="../../../clearpixel.gif" WIDTH=1 HEIGHT=1 BORDER=0></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD></TD>
                                    <TD COLSPAN=4 WIDTH=67 CLASS="TextObject">
                                        <P><c:out value="${param.year}"/>&nbsp;</P>
                                    </TD>
                                    <TD COLSPAN=3></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=8 HEIGHT=6></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=2></TD>
                                    <TD COLSPAN=4 WIDTH=67 CLASS="TextObject">
                                        <P><c:out value="${param.cuo_cod}"/>&nbsp;</P>
                                    </TD>
                                    <TD COLSPAN=2></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=8 HEIGHT=11></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=2></TD>
                                    <TD COLSPAN=4 WIDTH=67 CLASS="TextObject">
                                        <P><c:out value="${param.serial}"/>&nbsp;</P>
                                    </TD>
                                    <TD COLSPAN=2></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=8 HEIGHT=8></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=4></TD>
                                    <TD COLSPAN=4 WIDTH=67 CLASS="TextObject">
                                        <P><c:out value="${param.nber}"/>&nbsp;</P>
                                    </TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=8 HEIGHT=10></TD>
                                </TR>
                                <TR VALIGN=TOP ALIGN=LEFT>
                                    <TD COLSPAN=3></TD>
                                    <TD COLSPAN=4 WIDTH=67 CLASS="TextObject">
                                        <P><c:out value="${param.amount}"/>&nbsp;</P>
                                    </TD>
                                    <TD></TD>
                                </TR>
                            </TABLE>
                        </TD>
                    </TR>
                </TABLE>
                <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=301 NOF="LayoutRegion1">
                    <TR VALIGN=TOP ALIGN=LEFT>
                        <TD WIDTH=75 HEIGHT=11><IMG SRC="../../../clearpixel.gif" WIDTH=75 HEIGHT=1 BORDER=0></TD>
                        <TD WIDTH=226><IMG SRC="../../../clearpixel.gif" WIDTH=226 HEIGHT=1 BORDER=0></TD>
                    </TR>
                    <TR VALIGN=TOP ALIGN=LEFT>
                        <TD></TD>
                        <TD WIDTH=226 CLASS="TextObject">
                            <P><SPAN STYLE="font-size: medium;">Has been successfully paid:</SPAN></P>
                        </TD>
                    </TR>
                </TABLE>
				
                <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=543 NOF="LayoutRegion1">
                    <TR VALIGN=TOP ALIGN=LEFT>
                        <TD WIDTH=75 HEIGHT=5><IMG SRC="../../../clearpixel.gif" WIDTH=75 HEIGHT=1 BORDER=0></TD>
                        <TD WIDTH=468><IMG SRC="../../../clearpixel.gif" WIDTH=468 HEIGHT=1 BORDER=0></TD>
                    </TR>
                    <TR VALIGN=TOP ALIGN=LEFT>
                        <TD></TD>
                        <TD WIDTH=468 CLASS="TextObject">
                            <UL>
                                <LI><SPAN STYLE="font-size: medium;">Funds has been transferred to National Treasury account</SPAN>
                            </UL>
                        </TD>
                    </TR>
                </TABLE>
                <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=612 NOF="LayoutRegion1">
                    <TR VALIGN=TOP ALIGN=LEFT>
                        <TD WIDTH=76 HEIGHT=8><IMG SRC="../../../clearpixel.gif" WIDTH=76 HEIGHT=1 BORDER=0></TD>
                        <TD WIDTH=536><IMG SRC="../../../clearpixel.gif" WIDTH=536 HEIGHT=1 BORDER=0></TD>
                    </TR>
                    <TR VALIGN=TOP ALIGN=LEFT>
                        <TD></TD>
                        <TD WIDTH=536 CLASS="TextObject">
                            <UL>
                                <LI><SPAN STYLE="font-size: medium;">Customs Office Has been Notified: Receipt Id is<SPAN STYLE="color: rgb(102,204,102);"></SPAN> 
                                    <c:out value="${serviceResult.rcpYear}/${serviceResult.rcpSerial}/${serviceResult.rcpNber}"/>

</SPAN>
                            </UL>
                        </TD>
                    </TR>
                </TABLE>
                <br>
				</c:if>
				<%
				//Ending while 
				} 
            rs.close(); 
            s.close(); 
           con.close();   
	
		    
             } 
           catch (Exception e) {
          out.println(e.toString()); 
               } 
				
				
				
				%>
				
				<%
				
				//Ending Try
				}
        catch(SQLException ex){
        request.setAttribute("errorMsg","Failed to load the results");
        ex.printStackTrace();
         }
				
				%>
				
           </TD>
			
        </TR>
		
    </TABLE>
	
    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=233 NOF=LY>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD WIDTH=50 HEIGHT=8><IMG SRC="../../../clearpixel.gif" WIDTH=50 HEIGHT=1 BORDER=0></TD>
            <TD WIDTH=183><IMG SRC="../../../clearpixel.gif" WIDTH=183 HEIGHT=1 BORDER=0></TD>
        </TR>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD></TD>
            <TD WIDTH=183 CLASS="TextObject">
                <P><A HREF="../../../Income/Customs/customs.jsp">Return to customs payments</A></P>
            </TD>
        </TR>
    </TABLE>
    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 NOF=LY>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD WIDTH=47 HEIGHT=13><IMG SRC="../../../clearpixel.gif" WIDTH=47 HEIGHT=1 BORDER=0></TD>
            <TD></TD>
        </TR>
        <TR VALIGN=TOP ALIGN=LEFT>
            <TD></TD>
            <TD NOWRAP NOF="NB_FYHT" CLASS="TextNavBar">[<A HREF="../../../e-asy_bank.jsp">e-Asy Bank</A>]&nbsp;[<A HREF="../../../Cashier/cashier.jsp">Cashier</A>]&nbsp;[<A HREF="../../../Income/income.jsp">Income</A>]&nbsp;[<A
                 HREF="../../../Payments/payments.jsp">Payments</A>]&nbsp;[<A HREF="../../../Other/other.html">Other</A>]&nbsp;[<A HREF="../../../Sign_off/sign_off.html">Sign off</A>]</TD>
        </TR>
    </TABLE>
</BODY>
</HTML>
 


#2

You have 2 catches on your try, which is permissible, provided the syntax is correct.

should be
try {
//try something
} catch (SomeException se) {
//do something
} catch ( SomeOtherException soe ) {
//do something else
}

You have

try {
//try something
} catch (SomeException se ) {
//do something
}
} catch (SomeOtherException soe ) {
//do something else
}

Also, when using multiple catches, work from most specific to least specific - in your code, the Exception catch will catch everything and the SQLException catch will never be used (unless you rethrow the exception...)

#3

This is the error I am getting below.

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 272 in the generated java file
Syntax error on token "catch", Identifier expected

An error occurred at line: 274 in the generated java file
out cannot be resolved

An error occurred at line: 274 in the generated java file
jspxout cannot be resolved

An error occurred at line: 275 in the generated java file
out cannot be resolved

An error occurred at line: 275 in the generated java file
out cannot be resolved

An error occurred at line: 276 in the generated java file
out cannot be resolved

An error occurred at line: 277 in the generated java file
jspxpage_context cannot be resolved

An error occurred at line: 277 in the generated java file
jspxpage_context cannot be resolved

An error occurred at line: 279 in the generated java file
Syntax error on token "finally", delete this token

An error occurred at line: 280 in the generated java file
jspxpage_context cannot be resolved

An error occurred at line: 282 in the generated java file
Syntax error on token "}", delete this token

Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.

#4

I've scrolled through it twice now, I see code, but no error message.

Let's try this format

Hi, I'm getting the following error

(error message copied and pasted from compiler)

Here's my code:

(massive code block pared down to area that trouble seems to be emanating from)

Please, can someone help?

#5

what do you mean? error is there

#6

I'm pretty sure that it has to do with your JSP, which, according to the error message: "ERROR: user failed to post error message" has no solution.