File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Java code in jsp:include Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Java code in jsp:include" Watch "Java code in jsp:include" New topic

Java code in jsp:include

Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
I'm having a problem putting scriptlets into an include file. The file and the page that icludes it load fine when it's just HTML, but as soon as I add a scriptlet anywhere, the page loads up to the point of the jsp:include tag and stops. It doesn't even load the included file up to the point of the scriptlet.
Here's the code from the parent page:

The page I include is just HTML and a scriptlet - no <%@ page %> tag, no beans, nothing..
Any help would be greatly appreciated.
Mark Stein
Ranch Hand

Joined: May 20, 2002
Posts: 75
What's in your scriptlets, and did you name the page something.jsp?
If your scriptlet makes reference to a variable used on your current page, you'll need to use the <%@ include file %> rather than the <jsp:include /> tag.
Naveen Sharma
Ranch Hand

Joined: Mar 23, 2001
Posts: 65
<%@ include file %>
Files are embedded at compile time, when jsp is converting into a servlet
<jsp:include />
Files are dynamically loaded at run time
Hence if you are communicating in between two files through variable, u must embedd it as directive
Hope this may Help
* Naveen
I agree. Here's the link:
subject: Java code in jsp:include
It's not a secret anymore!