Mostly regarding Javascript, but there is some Java involved. I am using the Eclipse
IDE and I have the following type of code in a .jsp file.
<%
//some stuff
try {
//some java code
%>
<script type="text/javascript">
//Some javascript code to try
<% } catch(Exception e) {} %>
The issue is in the top portion of java, where it doesn't know that I later add in the catch(). I have an annoying error message showing up:
Multiple annotations found at this line:
- Syntax error, insert "Finally" to complete TryStatement
- Syntax error, insert "}" to complete ClassBody
While it has no effect on the compilation or actually causes any issues, I am curious if there is a way to suppress the warning so I don't have the red 'X' going up through all the folders?
It would be preferable if the solution did not affect the warnings in other files. I would give Imaginary Bonus Points for a solution which does not use Eclipse settings to handle the situation.
Solution: The reason the javascript code was in the try/catch was to keep it from running if an error was caught. Rather than doing it like above, it was reformatted like so:
<%
//some stuff
boolean valid = false;
try {
//some java code
valid = true;
} catch(Exception e) {} %>
<script type="text/javascript">
if (<%valid%>) {
//Some javascript code to try
}