jQuery validation plugin problem when served by JSP using @include


I'm trying to combine several JS files into one and serve it through JSP but I'm running into a problem with the jquery validation plugin 1.6

The JSP aggregating various .js files:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/javascript" pageEncoding="UTF-8"  %>

<c:if test="${jquery}">
    <%@include file="/js/jQuery/jquery-1.4.x.js" %>

<c:if test="${navMenu}">
    <%@include file="/js/verticalNavMenu.js.jsp" %>

<c:if test="${validate}">
    <%@include file="/js/jQuery/jquery.validate.js" %>

I've tested including the jQuery file and the custom verticalNavMenu file and all's fine

Including jquery.validate.js breaks the whole thing.

Here's the kicker though, if don't aggregate the validation plugin in the JSP file, but call it in the file that requires it ( form.jsp for example ) all work like a charm.

Any hints will be appreciated.


so you probably have something in one of those files that causes a syntax error in the JS when something else goes before or after it. You should look at the file and see what that is.

try putting


between the files, that might help. I cant help more without seeing the concatted file

The code looks fine. As per the comments ("jQuery is not defined"), the only cause for this problem would be that you included the jQuery validation file without including the jQuery core file itself. Thus, when ${validate} evaluates true, you should ensure that ${jquery} also evaluates true. You can also do that in the c:if block:

<c:if test="${jquery || validate}">
    <%@include file="/js/jQuery/jquery-1.4.x.js" %>

Need Your Help

How to make 'post' HTTP request in Swift?

swift authentication

I've a log in page in my app in which I'm doing authentication and making a post request.

Error: required operator not found in Macro: SAS

macros sas

I'm working on this macro (see below) and this statement is not resolving : %if (&amp;var_len > &amp;&amp;max&amp;i) %then %let max&amp;i=&amp;var_len; and the error that is returned is: ERROR: Req...