j2ee 1.3 import directives

Hello,

I am having problems with J2EE 1.3 beta deploying an application that uses jsp directives for importing. All the other developers in my team are using the 1.2 version of the J2EE SDK and have no problems, but I thought I would try the 1.3 version. In our JSPs, we have lines like:

<jsp:directive.page import="com.co.prj.beans.StaticBean" />

which don't seem to work in the 1.3 version unless they are changed to:

<%@ page import = "com.co.prj.beans.StaticBean" %>

When using the directive listed first (above), the jsp will not compile, because it is not importing the StaticBean class. Looking in the repository, I see the import statement is simply not there. I have tried modifying my classpath, moving the directive around in the code, and many other things, but to no avail.

If anyone has experienced anything like this, please let me know.

[915 byte] By [Schlepp] at [2007-9-26 3:59:22]
# 1

J2EE SDK 1.3 uses JSP 1.2

According to the JSP 1.2 specifications, it is illegal to mix standard JSP syntax and XML syntax inside the same source JSP file.

For example, the following code works for me...

<jsp:root version="1.2">

<jsp:directive.pageimport="java.util.*" />

<jsp:scriptlet>

HashMap theHashMap = new HashMap();

</jsp:scriptlet>

<jsp:cdata>theHashMap.size() is </jsp:cdata> <jsp:expression>theHashMap.size()</jsp:expression>

</jsp:root>

Maybe you are missing the <jsp:root> tag in your JSP.

neville_sequeira at 2007-6-29 12:53:19 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
what are you not using the <jsp:usebean> tag?
haroldsmith at 2007-6-29 12:53:19 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
We aren't using the usebean in this case because we don't want to instantiate the class, it is a static class.
Schlepp at 2007-6-29 12:53:19 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
Thanks for the info. I don't understand why this works fine with the J2EE SDK 1.2, but not with 1.3. Is it a new part of the spec to not allow the mixing of XML syntax with JSP syntax?
Schlepp at 2007-6-29 12:53:19 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5

Thats what it seems like.

It has been explicitly stated in the JSP 1.2 specifications. See section JSP.5.1 in the same.

There is not such explicit mention in JSP 1.1 specifications.

If you do...

<jsp:directive.pageimport="java.util.*" />

<%

java.util.HashMap theHashMap = new java.util.HashMap();

in your JSP, the first line will will be generated as it is in the HTML output. You can verify the same by do a 'view source' in the browser.

neville_sequeira at 2007-6-29 12:53:19 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...