Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Eclipse to syntax check inside <%@ include %> directives in JSP?

Tags:

java

eclipse

jsp

When I'm using <%@ include %> directives in JSP, is there any way to have Eclipse syntax check my included files (or what is best practice for this). What I mean is that if I include files that have variables declared in the parent, I get a bunch of errors about undeclared variables (makes sense).

So how do people get around this?

like image 826
Mason Avatar asked Jan 26 '10 20:01

Mason


People also ask

What is the syntax to include a file in JSP?

<jsp:directive.include file="relative URL"/> The included file's URL can be relative to the web application's context path or relative to the current JSP page.

What is the correct syntax for directive in JSP?

The Page directive defines a number of page dependent properties which communicates with the Web Container at the time of translation. Basic syntax of using the page directive is <%@ page attribute="value" %> where attributes can be one of the following : import attribute.

Which is the correct way to write a JSP directive inside a JSP page?

In JSP life cycle phase, JSP has to be converted to a servlet which is the translation phase. Directives can have many attributes by comma separated as key-value pairs. In JSP, directive is described in <%@ %> tags.

Where do we place a page directive within a JSP page?

The page directive is used to provide instructions to the container. These instructions pertain to the current JSP page. You may code page directives anywhere in your JSP page. By convention, page directives are coded at the top of the JSP page.


2 Answers

Disable JSP validation in Eclipse (it has always been a failure), or, better, just don't use scriptlets. It's considered bad practice. Keep Java code in real Java classes and use taglibs/EL in JSP all the way.

like image 118
BalusC Avatar answered Oct 25 '22 10:10

BalusC


The best practice is to encapsulate all Java code as tags, and then use the tags in your JSP. As a bonus when you do this you'll be writing your java in .java files, whose syntax Eclipse will check for you. You can find more information about tags from Sun

like image 27
justkt Avatar answered Oct 25 '22 10:10

justkt