Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JSP Compilation Error at line 0

Status
Not open for further replies.

nino2000

Programmer
Jun 23, 2001
26
FR
hi, when i created JSP pages , i got several times (often) an error when Jdeveloper compile JSP page to java file: Error [0] ; expected
but, it wasn't a problem because the JSP worked.

now, I meet an error very hard to resolve, i obtain:
Error [0] 'try' without 'catch'
or Error [0] 'catch' without 'try'

Could someone explain to me this strange error?
 
because your jsp is not correctly build
whatever you write in it, the main code should look like :
try {
//some code
}
catch(which error){
// some code
}

double check your code, you must be missing a } (or have an extra one !!)
 
To understand this error you have to remember that a jsp gets compiled down to a servlet. When it is being compiled the compiler throws in try-catch blocks to catch any exceptions and possibly redirect to an error page if one is specified. Therefore if you leave out a close bracket } it could cause some funky errors. The 'try' without 'catch' error is very common. The problem occurs since you code block will be ended by a } inserted by the compiler and cause the another compilation error elsewhere in the servlet code. This is what makes debugging jsps hard. Also note some servlet engines are better at identifing errors than others (WebLogic = good, Tomcat = bad). Wushutwist
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top