It's not a secret anymore!
The moose likes JSP and the fly likes JSP Compilation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Compilation" Watch "JSP Compilation" New topic

JSP Compilation

Praveen Dharmavaram
Ranch Hand

Joined: Nov 05, 2002
Posts: 59
I have a lot of JSP's which include other JSP's. I am trying to use the JSP compiler which comes with WebSphere 5.0. The JSP's wont compile and generate errors. When I dont compile and just have the servlet compile them at runtime, they compile without errors. Can Some one help me?

For Ex:-

String abc = "abc"

<%@ include file="test1.jsp" %>


<P> This is a test <%out.print(abc);%></P>
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

WSAD tries to look for compiler errors in the JSP as if it were standalone. At runtime, it uses the includes which results in a full pages.

A few ways around this:
1) Use the .jspf (jsp fragment) extension for the JSPs that go within a page. [I haven't tried this, but is should work]
2) Pass the variables are parameters or request scope attributes to avoid the compilation issue completely.
3) Turn off JSP validation. JSPs often flag errors falsely. You need to determine if there is extra value in having these things flagged or if you can just catch them when running the JSP.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
It is sorta covered in the JavaRanch Style Guide.
subject: JSP Compilation
jQuery in Action, 3rd edition