reset password
Author Message
tloi
Posts: 16
Posted 22:47 Apr 05, 2012 |

When modifying viewSections.jsp, the page shows errors like "javax.servlet.jsp.PageContext cannot be resolved to a type.", but  the code is run OK. Can I just turn off the JSP Syntax Validator? Or the errors related to missing some dependency or something else?

cysun
Posts: 2935
Posted 23:31 Apr 05, 2012 |

First of all, you shouldn't use scripting elements in JSP - use EL instead.

As for fixing the validation error, adding a jsp-api dependency should do it. The dependency is not needed to run the code because Tomcat already has jsp-api.jar.

tloi
Posts: 16
Posted 09:20 Apr 06, 2012 |

I just use EL to access pageContext. The line that evaluate requestURL is OK, but the line that evaluate requestURI show error "javax.servlet.jsp.JspException cannot be resolved to a type."

mrighetti
Posts: 20
Posted 13:29 Apr 11, 2012 |

If we add the jsp-api dependency to clear up the validation errors, should we commit the changed pom.xml to our repository? 

It seems that this would not hurt anything, but on the other hand it is not necessary.

cysun
Posts: 2935
Posted 13:33 Apr 11, 2012 |
mrighetti wrote:

If we add the jsp-api dependency to clear up the validation errors, should we commit the changed pom.xml to our repository? 

It seems that this would not hurt anything, but on the other hand it is not necessary.

Yes, you can add that dependency permanently to your project. If it helps clearing up validation errors, it's certainly necessary. You may want to set the dependency scope to "provided" since it's not needed in runtime.

mrighetti
Posts: 20
Posted 14:17 Apr 11, 2012 |

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>jsp-api</artifactId>
        <version>6.0.35</version>
        <scope>provided</scope>
    </dependency>

This is the one I added per a stackoverflow similar question.

cysun
Posts: 2935
Posted 16:28 Apr 11, 2012 |
mrighetti wrote:

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>jsp-api</artifactId>
        <version>6.0.35</version>
        <scope>provided</scope>
    </dependency>

This is the one I added per a stackoverflow similar question.

You probably want to add javax.servlet.jsp:javax.servlet.jsp-api:2.2.1 instead. The one you are using seems to be the one that comes with Tomcat 6.0.35 . The code should work with either dependency, but generally speaking it's better to stick with the standard API so you don't accidentally use Tomcat specific API.

mrighetti
Posts: 20
Posted 12:39 Apr 12, 2012 |

Will do.  Thanks.