I am using the following code to include some java script (- no error messages are being displayed, but it is not working):
<jsp:include page = "validation.js" flush = "true" />
I also placed this in the header tags:
As well as in the form tag I placed the usual code:
<form name="claimform1" onSubmit="return Claim(this)" id="claimform1" method="post" action="Claim_Form_2.jsp">
Last edited by Maria Modeste; 10-16-2005 at 08:50 AM.
Include .js file in a JSP page
I am also having an issue including a .js file on the JSP page. Need a few examples of how to code the page that includes the dynamic drop down list.
I am having the same problem including jQuery in my JSP:
I have a local copy of the jQuery file sitting in the root context and I'm using Tomcat 6.
<?xml version="1.0" encoding="UTF-8"?>
<jsp:directive.page contentType="text/html; charset=UTF-8" />
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
The text "Blank" does not appear and if I test any jQuery functionality, it doesn't work. This was tested in IE8 and Chrome with the same effect.
If I rewrite this in pure HTML, then the "Blank" text does appear:
Why is the script failing in JSP, but not in HTML?
<!DOCTYPE HTML "-//W3C//DTD XHTML 1.0 Strict//EN"
At a glance I'd say the problem is that you've specified the <jsp:output> element (which outputs the <html> element into the generated HTML) as an empty element. Thus your <head> and <body> elements are outside the generated <html> element, and since you've specified a valid DOCTYPE, the browser is in Standards mode and considers this a malformed document.
Remove the trailing slash in the <jsp:output> tag, and add a closing </jsp:output> tag after your closing </body> tag. That should give a valid HTML document for your browser to parse.
I'm afraid <jsp:output> is not allowed to have a body, so it must always be written <jsp:output />
The only workaround that I've found that works is a full inclusion of the js file in the body of the page, like so:
<jsp:include page="jquery-1.4.4.min.js" />
Sorry about that. I was assuming that the <jsp:output> tag caused the JSP processor to output an <html> element. It doesn't, and I still think that's the root cause of your problem--the JSP-generated HTML output is not valid for the DOCTYPE you've specified, because your JSP code does not output an <html> element. Try adding in the <html> element and see if that fixes your problem.
However, the <jsp:root> element does generate an <html> element and it correctly envelops the <head> and <body> tags.
Nevertheless, JSPX does not require <jsp:root> as the root element, so I tried it out replacing it with <html>, but unfortunately the same HTML was generated as before.
No luck I'm afraid.
By jase_dukerider in forum C++
Last Post: 04-14-2005, 08:48 PM
By Tomer Cagan in forum ASP.NET
Last Post: 07-24-2001, 10:01 AM
By Beginner in forum ASP.NET
Last Post: 12-01-2000, 12:45 PM
By Paul in forum Database
Last Post: 08-22-2000, 11:54 PM
Last Post: 05-31-2000, 11:30 AM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL