219761 Syntax error reported at wrong location
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPIncludeRegionHelper.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPIncludeRegionHelper.java
index 2f09f1e..f0115c8 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPIncludeRegionHelper.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPIncludeRegionHelper.java
@@ -26,8 +26,8 @@
 	/**
 	 * @param JSPTranslator
 	 */
-	public JSPIncludeRegionHelper(JSPTranslator translator) {
-		super(translator);
+	public JSPIncludeRegionHelper(JSPTranslator translator, boolean appendAsIndirectSource) {
+		super(translator, appendAsIndirectSource);
 	}
 
 	// these methods determine what content gets added to the local scriplet, expression, declaration buffers
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java
index 790cfa6..b200937 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java
@@ -838,7 +838,7 @@
 			for (int i = 0; i < taglibVars.length; i++) {
 				if (taglibVars[i].getScope() == VariableInfo.AT_BEGIN) {
 					decl = taglibVars[i].getDeclarationString();
-					appendToBuffer(decl, fUserCode, false, fCurrentNode);
+					appendToBuffer(decl, fUserCode, false, customTag);
 				}
 				if (taglibVars[i].getScope() == VariableInfo.AT_END) {
 					decl = taglibVars[i].getDeclarationString();
@@ -848,8 +848,8 @@
 			for (int i = 0; i < taglibVars.length; i++) {
 				if (taglibVars[i].getScope() == VariableInfo.NESTED) {
 					decl = taglibVars[i].getDeclarationString();
-					appendToBuffer("{", fUserCode, false, fCurrentNode);
-					appendToBuffer(decl, fUserCode, false, fCurrentNode);
+					appendToBuffer("{", fUserCode, false, customTag);
+					appendToBuffer(decl, fUserCode, false, customTag);
 					fTagToVariableMap.push(tagToAdd, taglibVars);
 				}
 			}
@@ -860,14 +860,14 @@
 				 */
 				for (int i = taglibVars.length; i > 0; i--) {
 					if (taglibVars[i - 1].getScope() == VariableInfo.NESTED) {
-						appendToBuffer("}", fUserCode, false, fCurrentNode);
+						appendToBuffer("}", fUserCode, false, customTag);
 					}
 				}
 				/* Treat this as the end for empty tags */
 				for (int i = 0; i < taglibVars.length; i++) {
 					if (taglibVars[i].getScope() == VariableInfo.AT_END) {
 						decl = taglibVars[i].getDeclarationString();
-						appendToBuffer(decl, fUserCode, false, fCurrentNode);
+						appendToBuffer(decl, fUserCode, false, customTag);
 					}
 				}
 			}
@@ -881,13 +881,13 @@
 			if (taglibVars != null) {
 				for (int i = taglibVars.length; i > 0; i--) {
 					if (taglibVars[i - 1].getScope() == VariableInfo.NESTED) {
-						appendToBuffer("}", fUserCode, false, fCurrentNode);
+						appendToBuffer("}", fUserCode, false, customTag);
 					}
 				}
 				for (int i = 0; i < taglibVars.length; i++) {
 					if (taglibVars[i].getScope() == VariableInfo.AT_END) {
 						decl = taglibVars[i].getDeclarationString();
-						appendToBuffer(decl, fUserCode, false, fCurrentNode);
+						appendToBuffer(decl, fUserCode, false, customTag);
 					}
 				}
 			}
@@ -1044,6 +1044,9 @@
 	/**
 	 * translates a region container (and XML JSP container, or <% JSP
 	 * container)
+	 * 
+	 * This method should only be called in this class and for containers in
+	 * the primary structured document as all buffer appends will be direct
 	 */
 	protected void translateRegionContainer(ITextRegionCollection container, int JSPType) {
 
@@ -1210,7 +1213,7 @@
 	 * @return
 	 */
 	private void decodeScriptBlock(String blockText, int startOfBlock) {
-		XMLJSPRegionHelper helper = new XMLJSPRegionHelper(this);
+		XMLJSPRegionHelper helper = new XMLJSPRegionHelper(this, false);
 		helper.addBlockMarker(new BlockMarker("jsp:scriptlet", null, DOMJSPRegionContexts.JSP_CONTENT, false)); //$NON-NLS-1$
 		helper.addBlockMarker(new BlockMarker("jsp:expression", null, DOMJSPRegionContexts.JSP_CONTENT, false)); //$NON-NLS-1$
 		helper.addBlockMarker(new BlockMarker("jsp:declaration", null, DOMJSPRegionContexts.JSP_CONTENT, false)); //$NON-NLS-1$
@@ -1279,7 +1282,7 @@
 			{
 				String fullTagName = container.getText(r);
 				if (fullTagName.indexOf(':') > -1) {
-					addTaglibVariables(fullTagName, getCurrentNode()); // it
+					addTaglibVariables(fullTagName, container); // it
 					// may
 					// be a
 					// custom
@@ -1509,13 +1512,13 @@
 	private void writeToBuffer(int type, String content, int jspStart, int jspEnd) {
 		switch (type) {
 			case SCRIPTLET :
-				translateScriptletString(content, getCurrentNode(), jspStart, jspEnd - jspStart);
+				translateScriptletString(content, getCurrentNode(), jspStart, jspEnd - jspStart, false);
 				break;
 			case EXPRESSION :
-				translateExpressionString(content, getCurrentNode(), jspStart, jspEnd - jspStart);
+				translateExpressionString(content, getCurrentNode(), jspStart, jspEnd - jspStart, false);
 				break;
 			case DECLARATION :
-				translateDeclarationString(content, getCurrentNode(), jspStart, jspEnd - jspStart);
+				translateDeclarationString(content, getCurrentNode(), jspStart, jspEnd - jspStart, false);
 				break;
 		}
 	}
@@ -1699,19 +1702,19 @@
 					fLastJSPType = EXPRESSION;
 					// translateExpressionString(embeddedContainer.getText(content),
 					// fCurrentNode, contentStart, content.getLength());
-					translateExpressionString(embeddedContainer.getText(content), embeddedContainer, contentStart, content.getLength());
+					translateExpressionString(embeddedContainer.getText(content), embeddedContainer, contentStart, content.getLength(), false);
 				}
 				else if (type == DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN) {
 					fLastJSPType = SCRIPTLET;
 					// translateScriptletString(embeddedContainer.getText(content),
 					// fCurrentNode, contentStart, content.getLength());
-					translateScriptletString(embeddedContainer.getText(content), embeddedContainer, contentStart, content.getLength());
+					translateScriptletString(embeddedContainer.getText(content), embeddedContainer, contentStart, content.getLength(), false);
 				}
 				else if (type == DOMJSPRegionContexts.JSP_DECLARATION_OPEN) {
 					fLastJSPType = DECLARATION;
 					// translateDeclarationString(embeddedContainer.getText(content),
 					// fCurrentNode, contentStart, content.getLength());
-					translateDeclarationString(embeddedContainer.getText(content), embeddedContainer, contentStart, content.getLength());
+					translateDeclarationString(embeddedContainer.getText(content), embeddedContainer, contentStart, content.getLength(), false);
 				}
 				else if (type == DOMJSPRegionContexts.JSP_EL_OPEN) {
 					fLastJSPType = EXPRESSION;
@@ -2068,7 +2071,7 @@
 
 				if (!getIncludes().contains(filePathString) && !filePathString.equals(modelPath.toString())) {
 					getIncludes().push(filePathString);
-					JSPIncludeRegionHelper helper = new JSPIncludeRegionHelper(this);
+					JSPIncludeRegionHelper helper = new JSPIncludeRegionHelper(this, true);
 					// Should we consider preludes on this segment?
 					helper.parse(filePathString);
 					getIncludes().pop();
@@ -2087,14 +2090,14 @@
 		return fIncludedPaths;
 	}
 
-	protected void translateExpressionString(String newText, ITextRegionCollection embeddedContainer, int jspPositionStart, int jspPositionLength) {
+	protected void translateExpressionString(String newText, ITextRegionCollection embeddedContainer, int jspPositionStart, int jspPositionLength, boolean isIndirect) {
 		appendToBuffer(EXPRESSION_PREFIX, fUserCode, false, embeddedContainer);
-		appendToBuffer(newText, fUserCode, true, embeddedContainer, jspPositionStart, jspPositionLength);
+		appendToBuffer(newText, fUserCode, true, embeddedContainer, jspPositionStart, jspPositionLength, isIndirect);
 		appendToBuffer(EXPRESSION_SUFFIX, fUserCode, false, embeddedContainer);
 	}
 
-	protected void translateDeclarationString(String newText, ITextRegionCollection embeddedContainer, int jspPositionStart, int jspPositionLength) {
-		appendToBuffer(newText, fUserDeclarations, true, embeddedContainer, jspPositionStart, jspPositionLength);
+	protected void translateDeclarationString(String newText, ITextRegionCollection embeddedContainer, int jspPositionStart, int jspPositionLength, boolean isIndirect) {
+		appendToBuffer(newText, fUserDeclarations, true, embeddedContainer, jspPositionStart, jspPositionLength, isIndirect);
 		appendToBuffer(ENDL, fUserDeclarations, false, embeddedContainer);
 	}
 
@@ -2106,32 +2109,32 @@
 	 * @param jspPositionStart
 	 * @param jspPositionLength
 	 */
-	protected void translateScriptletString(String newText, ITextRegionCollection embeddedContainer, int jspPositionStart, int jspPositionLength) {
-		appendToBuffer(newText, fUserCode, true, embeddedContainer, jspPositionStart, jspPositionLength);
+	protected void translateScriptletString(String newText, ITextRegionCollection embeddedContainer, int jspPositionStart, int jspPositionLength, boolean isIndirect) {
+		appendToBuffer(newText, fUserCode, true, embeddedContainer, jspPositionStart, jspPositionLength, isIndirect);
 	}
 
 	// the following 3 methods determine the cursor position
 	// <%= %>
 	protected void translateExpression(ITextRegionCollection region) {
 		String newText = getUnescapedRegionText(region, EXPRESSION);
-		appendToBuffer(EXPRESSION_PREFIX, fUserCode, false, fCurrentNode);
+		appendToBuffer(EXPRESSION_PREFIX, fUserCode, false, region);
 		appendToBuffer(newText, fUserCode, true, fCurrentNode);
-		appendToBuffer(EXPRESSION_SUFFIX, fUserCode, false, fCurrentNode);
+		appendToBuffer(EXPRESSION_SUFFIX, fUserCode, false, region);
 	}
 
 	//
 	// <%! %>
 	protected void translateDeclaration(ITextRegionCollection region) {
 		String newText = getUnescapedRegionText(region, DECLARATION);
-		appendToBuffer(newText, fUserDeclarations, true, fCurrentNode);
-		appendToBuffer(ENDL, fUserDeclarations, false, fCurrentNode);
+		appendToBuffer(newText, fUserDeclarations, true, region);
+		appendToBuffer(ENDL, fUserDeclarations, false, region);
 	}
 
 	//
 	// <% %>
 	protected void translateScriptlet(ITextRegionCollection region) {
 		String newText = getUnescapedRegionText(region, SCRIPTLET);
-		appendToBuffer(newText, fUserCode, true, fCurrentNode);
+		appendToBuffer(newText, fUserCode, true, region);
 	}
 
 	/**
@@ -2152,10 +2155,6 @@
 		appendToBuffer(newText, buffer, addToMap, jspReferenceRegion, start, length, false);
 	}
 
-	private void appendToBuffer(String newText, StringBuffer buffer, boolean addToMap, ITextRegionCollection jspReferenceRegion, int jspPositionStart, int jspPositionLength) {
-		appendToBuffer(newText, buffer, addToMap, jspReferenceRegion, jspPositionStart, jspPositionLength, true);
-	}
-
 	/**
 	 * Adds newText to the buffer passed in, and adds to translation mapping
 	 * as specified by the addToMap flag. some special cases to consider (that
@@ -2826,7 +2825,7 @@
 				for (int i = 0; i < codas.length; i++) {
 					if (!getIncludes().contains(codas[i].toString()) && !codas[i].equals(modelpath)) {
 						getIncludes().push(codas[i]);
-						JSPIncludeRegionHelper helper = new JSPIncludeRegionHelper(this);
+						JSPIncludeRegionHelper helper = new JSPIncludeRegionHelper(this, true);
 						helper.parse(codas[i].toString());
 						getIncludes().pop();
 					}
@@ -2846,7 +2845,7 @@
 				for (int i = 0; i < preludes.length; i++) {
 					if (!getIncludes().contains(preludes[i].toString()) && !preludes[i].equals(modelpath)) {
 						getIncludes().push(preludes[i]);
-						JSPIncludeRegionHelper helper = new JSPIncludeRegionHelper(this);
+						JSPIncludeRegionHelper helper = new JSPIncludeRegionHelper(this, true);
 						helper.parse(preludes[i].toString());
 						getIncludes().pop();
 					}
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java
index c57d86f..0535b36 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java
@@ -58,10 +58,16 @@
 	protected String fStrippedText = ""; //$NON-NLS-1$
 	// for reconciling cursor position later
 	int fPossibleOwner = JSPTranslator.SCRIPTLET;
+	/**
+	 * Determines whether translated source appends are indicated as
+	 * "indirect", affecting how offsets are mapped.
+	 */
+	boolean fAppendAsIndirectSource;
 
-	public XMLJSPRegionHelper(JSPTranslator translator) {
+	public XMLJSPRegionHelper(JSPTranslator translator, boolean appendAsIndirectSource) {
 		getLocalParser().addStructuredDocumentRegionHandler(this);
 		this.fTranslator = translator;
+		fAppendAsIndirectSource = appendAsIndirectSource;
 	}
 
 	protected JSPSourceParser getLocalParser() {
@@ -251,7 +257,7 @@
 		text.append("{ // <"); //$NON-NLS-1$
 		text.append(tagName);
 		text.append(">\n"); //$NON-NLS-1$
-		this.fTranslator.translateScriptletString(text.toString(), currentNode, currentNode.getStartOffset(), currentNode.getLength()); //$NON-NLS-1$
+		this.fTranslator.translateScriptletString(text.toString(), currentNode, currentNode.getStartOffset(), currentNode.getLength(), fAppendAsIndirectSource); //$NON-NLS-1$
 
 	}
 
@@ -261,7 +267,7 @@
 		text.append("} // </"); //$NON-NLS-1$
 		text.append(tagName);
 		text.append(">\n"); //$NON-NLS-1$
-		this.fTranslator.translateScriptletString(text.toString(), currentNode, currentNode.getStartOffset(), currentNode.getLength()); //$NON-NLS-1$
+		this.fTranslator.translateScriptletString(text.toString(), currentNode, currentNode.getStartOffset(), currentNode.getLength(), fAppendAsIndirectSource); //$NON-NLS-1$
 
 	}
 
@@ -290,21 +296,21 @@
 	protected void processDeclaration(IStructuredDocumentRegion sdRegion) {
 		prepareText(sdRegion);
 		IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
-		this.fTranslator.translateDeclarationString(fStrippedText, currentNode, currentNode.getStartOffset(), currentNode.getLength());
+		this.fTranslator.translateDeclarationString(fStrippedText, currentNode, currentNode.getStartOffset(), currentNode.getLength(), fAppendAsIndirectSource);
 		fPossibleOwner = JSPTranslator.DECLARATION;
 	}
 
 	protected void processExpression(IStructuredDocumentRegion sdRegion) {
 		prepareText(sdRegion);
 		IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
-		this.fTranslator.translateExpressionString(fStrippedText, currentNode, currentNode.getStartOffset(), currentNode.getLength());
+		this.fTranslator.translateExpressionString(fStrippedText, currentNode, currentNode.getStartOffset(), currentNode.getLength(), fAppendAsIndirectSource);
 		fPossibleOwner = JSPTranslator.EXPRESSION;
 	}
 
 	protected void processScriptlet(IStructuredDocumentRegion sdRegion) {
 		prepareText(sdRegion);
 		IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
-		this.fTranslator.translateScriptletString(fStrippedText, currentNode, currentNode.getStartOffset(), currentNode.getLength());
+		this.fTranslator.translateScriptletString(fStrippedText, currentNode, currentNode.getStartOffset(), currentNode.getLength(), fAppendAsIndirectSource);
 		fPossibleOwner = JSPTranslator.SCRIPTLET;
 	}
 
@@ -350,7 +356,7 @@
 			}
 
 			IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
-			this.fTranslator.translateScriptletString(beanDecl, currentNode, currentNode.getStartOffset(), currentNode.getLength());
+			this.fTranslator.translateScriptletString(beanDecl, currentNode, currentNode.getStartOffset(), currentNode.getLength(), fAppendAsIndirectSource);
 			fPossibleOwner = JSPTranslator.SCRIPTLET;
 		}
 	}
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPJavaValidator.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPJavaValidator.java
index 9972e34..00aec88 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPJavaValidator.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPJavaValidator.java
@@ -83,7 +83,6 @@
 		IStructuredDocumentRegion[] regions = sDoc.getStructuredDocumentRegions(0, m.getOffset() + m.getLength());
 		// iterate backwards until you hit the include directive
 		for (int i = regions.length - 1; i >= 0; i--) {
-
 			IStructuredDocumentRegion region = regions[i];
 			if (region.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) {
 				if (getDirectiveName(region).equals("include")) { //$NON-NLS-1$
@@ -96,6 +95,11 @@
 						m.setOffset(region.getStartOffset());
 						m.setLength(region.getTextLength());
 					}
+					/**
+					 * Bug 219761 - Syntax error reported at wrong location
+					 * (don't forget to adjust the line number, too)
+					 */
+					m.setLineNo(sDoc.getLineOfOffset(m.getOffset()) + 1);
 					break;
 				}
 			}
@@ -103,7 +107,7 @@
 	}
 
 	/**
-	 * Creates an IMessage from an IProblem
+	 * Creates an IMessage from asn IProblem
 	 * 
 	 * @param problem
 	 * @param f