Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 86783 - Imports (in include files?)
Summary: Imports (in include files?)
Status: CLOSED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: jst.jsp (show other bugs)
Version: 1.5   Edit
Hardware: PC Linux-GTK
: P3 normal with 1 vote (vote)
Target Milestone: 1.5 M5   Edit
Assignee: Phillip Avery CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-27 11:57 EST by Jason Calabrese CLA
Modified: 2006-09-20 15:51 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Calabrese CLA 2005-02-27 11:57:31 EST
I found a problem with some of my pages where imports weren't being found. 
 
I turns out that the problem was the formatting of the import tags. 
   
In the include file the imports were formatted like this:   
<%@ page import="java.io.*" %><%@   
    page import="java.net.*" %><%@   
    page import="java.util.*" %><%@   
    page import="java.sql.*" %>   
   
The problem was fixed by formatting the imports like this:   
<%@page import="java.io.*" %>   
<%@page import="java.net.*" %>   
<%@page import="java.util.*" %>   
<%@page import="java.sql.*" %>   
   
I bet there there is a regex somewhere that needs to be tweeked.
Comment 1 ssauder CLA 2005-05-04 09:46:22 EDT
This bug, or at least remains of it, still exist in WTP 1.0-M4. Page and Include
directives that are immediately followed by other directives or scriptlets
(without whitespace in between) are not properly "inherited" if you include the
jsp that contains them.

The following example compiles and runs fine on tomcat, but the jsp-editor
complains that 
- in including.jsp: "The method format(int) is undefined..."
- in included.jsp: ParseException cannot be resolved to a type (in file:
"nested.jsp")

Both errors disappear if I put some whitespace after the directive, but there
are many situations where you can't accept whitespace at the beginning of your
jsp output.



nested.jsp:
<%@ page import="java.text.ParseException" %><%!
private java.text.NumberFormat currencyFormat =
java.text.NumberFormat.getCurrencyInstance();

public String formatCurrency(double value) throws ParseException {
  return currencyFormat.format(value);
}
%>

included.jsp:
<%@ include file="nested.jsp" %><%!
// Imagine more stuff here
%>

including.jsp:
<%@ include file="included.jsp" %><%
out.println(formatCurrency(100));
%>

Comment 2 Nitin Dahyabhai CLA 2005-05-10 22:12:43 EDT
Is it that the JSPIncludeRegionHelper.isJSPStartRegion() returns true for
jsp_directive_open, preventing processOtherRegions() from being called and
nesting the includes properly?
Comment 3 David Williams CLA 2005-06-15 01:21:54 EDT
Changed Version field given new release numbering.
Comment 4 Øyvind L. Eggen CLA 2005-07-08 07:55:29 EDT
This bug still exists in M5 and I20050708. Here is a "minimal" implementation to
demonstrate the bug:

---------include.jsp----------
<%@page import="java.util.Vector" %><% Vector v = new Vector(); %>
------------------------------

-----------page.jsp-----------
<%@include file="include.jsp" %>
------------------------------

The JSP editor indicates an error in the include statement in page.jsp with the
message "Vector cannot be resolved to a type (in file: "include.jsp")".
Comment 5 Nitin Dahyabhai CLA 2005-08-04 23:16:05 EDT
Reproduced.  It happens consistently as long as the directive and scriptlet in
include.jsp have no separating whitespace.
Comment 6 Phillip Avery CLA 2006-01-17 09:43:48 EST
This is a bug in XMLJSPRegionHelper#nodeParsed()

The logic always assumes a tag that we want to translate is followed by content (xml content or jsp content).  This it true for scriptlets, expressions and declarations, but not for page directives, jsp:useBean, and includes.

If we move the logic for those cases to the "if" part of the block above where it currently is (below where code handles recognizing the tagname) that should fix the problem.

This would be a good candidate for a unit test as well.
Comment 7 Phillip Avery CLA 2006-01-17 11:32:00 EST
fix tested and released to HEAD.
Comment 8 David Williams CLA 2006-03-04 01:05:03 EST
This change is a bulk update of all _un_targeted, fixed, resolved bugs upon release of M5. This particular bug _might_ have been fixed earlier than M5. (Feel free to correct). 

Comment 9 Amy Wu CLA 2006-09-20 15:51:44 EDT
closing