views:

373

answers:

2

Greetings!

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>

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

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

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.

+1  A: 

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

mkoryak
+1  A: 

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" %>
</c:if>
BalusC