1

I'm trying to work with jsp "fragments" (template files) encoded in UTF-8 in NetBeans 1 outside any project 2. Please, notice that I'm talking about "jsp fragments," that is, I don't think that I can add the <%@page%> directive, as this would result in duplicated encodings directives 3 when building the final page 4.

As I have reported in NetBeans' bugzilla Bug 212395 - Cannot edit UTF-8 JSPs fragments in Favorites (not in projects), I haven't found any way to do this. Does anyone have any hint?

I have already read How do you set the encoding to utf-8 in netbeans 6.9?, How to change file encoding in NetBeans? and Saving JSP as UTF-8 in NetBeans, but the solution in all of them is based on configuring a NetBeans project that I don't have. (I open the file from the WebDAV with File -> Open File...)

The -J-Dfile.encoding=UTF-8 option does not have any effect at all, and my locale is also ignored (as expected after reading NetBean's Project Encoding vs. File Encoding - What are the precedence rules used in NetBeans 6.x?


Notes:

  1. NetBeans IDE 7.1.2
  2. The jsp files live in a mounted WebDAV filesystem
  3. From the specs (JSR-000245 JavaServer Pages 2.1 FR):

    The pageEncoding attribute can occur at most once per file (or a translation error will result), and applies only to the file in which it appears.

  4. The jsp's are opencms pages that are stitched together using <cms:include> tags

Community
  • 1
  • 1
Alberto
  • 5,021
  • 4
  • 46
  • 69
  • Side note: Since you mention OpenCms and WebDav in that context, note that my experience with using WebDav and OpenCms is, that there are a few issues and that WebDav therefore isn't reliably usable imho. Or have you been using it successfully so far? See my post at http://lists.opencms.org/pipermail/opencms-dev/2011q2/035795.html – Mathias Conradt May 12 '12 at 01:33
  • @MathiasLin Thanks for your remark. I knew from one colleague that WebDav doesn't work flawlessly (at least, not for everyone). After checking github-bugtracker and the mailing list for WebDAV issues in OpenCms 8+, I thought that it could still be worthy giving it a chance. I'm new to OpenCms and now trying to find if we could improve our current "legacy-ad-hoc" development process. I'm using WebDAV currently only for inspecting existing code and doing small changes in existing files...No problems found so far. – Alberto May 14 '12 at 11:44

1 Answers1

1

After re-reading the JSP specs (link provided before), it seems that it is possible to include the page directive more than once per "translation unit:"

A translation unit (JSP source file and any files included via the include directive) can contain more than one instance of the page directive [...] There shall be only one occurrence of any attribute/value pair defined by this directive in a given translation unit, unless the values for the duplicate attributes are identical for all occurrences. The import and pageEncoding attributes are exempt from this rule and can appear multiple times. [...] The pageEncoding attribute can occur at most once per file (or a translation error will result), and applies only to the file in which it appears.

It seems that I can solve the problem adding the page directive once per file.

Alberto
  • 5,021
  • 4
  • 46
  • 69