Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent to java @SuppressWarnings in JSP

Tags:

jsp

warnings

The question is in the title : "Is there an equivalent to java @SuppressWarnings in JSP ?"

like image 262
Vinze Avatar asked Jan 28 '09 14:01

Vinze


People also ask

What does @SuppressWarnings mean in Java?

Use of @SuppressWarnings is to suppress or ignore warnings coming from the compiler, i.e., the compiler will ignore warnings if any for that piece of code. 1. @SuppressWarnings("unchecked") public class Calculator { } - Here, it will ignore all unchecked warnings coming from that class.

What does @SuppressWarnings mean?

@SuppressWarnings instruct the compiler to ignore or suppress, specified compiler warning in annotated element and all program elements inside that element. For example, if a class is annotated to suppress a particular warning, then a warning generated in a method inside that class will also be separated.

What is @SuppressWarnings Rawtypes?

You can use the @SuppressWarnings("unchecked") which is supported by both the eclipse compiler and javac. But remember the @SuppressWarnings annotation is used by your compiler which can have its own values. The JLS only forces the compiler to understand the values "unchecked" and "deprecated" (for now).


2 Answers

Yes, just use:

<%! @SuppressWarnings("unchecked") %>
like image 79
Brett Avatar answered Oct 15 '22 23:10

Brett


If you are getting warnings in the code generated from a JSP (or in in-line code in a JSP), one solution is to move the problem code into a Servlet or into a utility class. That way you can mark it up to your heart's content, and your JSP has less Java code in it. Win-win!

like image 25
Eddie Avatar answered Oct 15 '22 21:10

Eddie