facebook

JSPEditor Problems(open .html and false jsp validation errs)

  1. MyEclipse Archived
  2.  > 
  3. UML Development
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #235806 Reply

    I am having some problems with the JSP Editor. My configuration is as follows:
    OS: WinXP SP2
    Eclipse: Version: 3.1.0 Build id: I20050627-1435
    Eclipse WAS freshly installed for MyEclipse
    No external plugins are installed
    There are 4 plugins in the <eclipse>/plugins directory that are like org.eclipse.pde.*
    MyEclipse version: Version: 3.9.310 Build id: 20050808-4.0-Milestone-3
    JDK version: 1.4.2_03
    There are no exceptions in the <workspace>/.metadata/.log file.

    Problem One: Unable to open .html files with the JSP Editor. I already added the “MyEclipse JSP Designer” for ‘*.html’ files using the Window->Preferences->General->Editors->”File Associations”. I right click on the .html file and choose “Open With”->”MyEclipse JSP Designer”. The source view shows validation errors with any and all JSP snippets, directives, etc. Choosing the “Design” view, I only see “HTML-Basic” and “HTML-form” on the Palette and if I go back to Source view and right click on the editor pane and choose Preferences, I only see “Common Editor Preferences” and HTML Editor Preferences. Sample code as follows:

    
    <% System.out.println("howdy"); %>
    <html>
        <head><title>Howdy</title></head>
        <body>
            Hello there
        </body>
    </html>
    

    …results in the error “Invalid text string (<% System.out.println(“howdy”); %>)”.

    Problem Two: Improper JSP Validation Errors in the JSP Editor for a .jsp fragment. In the Window->Preferences->MyEclipse->Editors->JSP–>’JSP Fragment Extensions’, my extensions are (w/o the quotes) “html, jsp, htm, jspf”. When opening a JSP file in the JSP Editor, I get validation errors that should not be there. The following code is the only thing in the file:

    
    <table>
        <tr>
            <td>hi</td>
        </tr>
    </table>
    

    …. results in the error “Invalid location of tag (table).”

    Overall, I am excited about your product. I hope to replace my current commercial JSP/”web tools” plugin with MyEclipse. So far the only things preventing me from doing so are the 2 problems mentioned above, and the lack of EL support as mentioned in this thread. Once these items are fixed (and assuming no new issues :p), I plan to use MyEclipse exclusively for my web development.

    Thanks,
    jlilly

    #235825 Reply

    Riyad Kalla
    Member

    Problem One: Unable to open .html files with the JSP Editor.

    I read further on to understand that these .html files are actually JSP files that you named with the .html extension. Out of curiosity, if you rename the file (temporarily) to .jsp, does everything work correctly?

    I would add that I believe naming these files .html if they are .jsp files is invalid, as the app server wouldn’t have any way to know if it should compile the page or not. While this *may* work on Tomcat (or whatever app server you are using) I don’t think it’s entirely kosher. If renaming the file to .jsp worked above, then I’ll discuss the issue with the devs and see if .jsp is required for JSP pages.

    TIP: If you just don’t want users to see .jsp extensions, that is what url-mappings are used for in the web.xml file. You want to leave your code as pure as possible and just make use of mappings to provide whatever “look” to the URL you want/need.

    …. results in the error “Invalid location of tag (table).”

    If you are opening the fragment with the HTML editor I can understand this, are you using the JSP editor? What is the extension on this file?

    I plan to use MyEclipse exclusively for my web development.

    Glad to hear it. I’ll admit your question is a bit unorthodox and might require some finessing, but we’ll do what we can to get it working for you.

    #235940 Reply

    Note: I am usually using the JSP Designer when I refer to the JSP Editor, though I witness the same with both ‘editors’.

    Out of curiosity, if you rename the file (temporarily) to .jsp, does everything work correctly?

    Yes, opening a JSP file does in fact open the JSP Editor. However, I am wanting to use the JSP Editor with files ending in with ‘.html’. This thread as well as this one suggest that you can associate a particular filetype with a particular editor. I followed support-scott’s recommendation from that first thread:

    To add a new editor as an option for a particular file suffix, you need to add it to Window > Preferences > General > Editors > File Associations > *.jsp and click ‘Add…’ and select MyEclipse XML Editor.

    …but I selected the JSP Designer rather than “MyEclipse XML Editor”. This should be a simple matter of editor/filetype association. If I follow the same steps and choose “MyEclipse XML Editor”, it does in fact use the XML Editor when I right-click, “Open With”->”MyEclipse XML Editor”. However, the behavior when I choose “MyEclipse JSP Designer” is to override my decision and use the HTML Designer instead.

    I would add that I believe naming these files .html if they are .jsp files is invalid, as the app server wouldn’t have any way to know if it should compile the page or not. While this *may* work on Tomcat (or whatever app server you are using) I don’t think it’s entirely kosher. If renaming the file to .jsp worked above, then I’ll discuss the issue with the devs and see if .jsp is required for JSP pages.

    You can name your files with any suffix as long as you specify in the web.xml how to have it “served”. We use the following in resin2 (which can also be done in any other servlet container I have come across).

      <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.html</url-pattern>
      </servlet-mapping>
      <servlet-mapping>
        <servlet-name>jsp</servlet-name>
        <url-pattern>*.htm</url-pattern>
      </servlet-mapping>

    There are a number of sites which choose various file extensions for various reasons. I do not really have an opinion on its ‘kosherness’. This is simply the file structure with which I am dealing. I am just hoping that MyEclipseIDE can have the flexibility that standardly comes with Eclipse plugins.

    …. results in the error “Invalid location of tag (table).”

    If you are opening the fragment with the HTML editor I can understand this, are you using the JSP editor? What is the extension on this file?

    This occurs when opening a JSP file (with a ‘.jsp’ file extension) that has only the following HTML code:

    <table>
       <tr>
          <td>hi</td>
       </tr>
    </table> 
    

    The same error is given if I rename to file with a ‘.jspf’ extension and reopen with the JSP Editor.

    I understand that many would argue that jsp files SHOULD end with ‘.jsp’ and JSP fragments SHOULD end with ‘.jspf’, but when Eclipse lets you specify a file association (Window->Preferences->General->Editors->”File Associations”) and the MyEclipseIDE plugin lets you specify “JSP Fragment Extensions (Window->Preferences->MyEclipse->Editors->JSP), it would seem to be explicitly stated that what I am attempting to do is valid.

    #235954 Reply

    Riyad Kalla
    Member

    I checked with one of the devs that works on the JSP editor and he says you should be fine with the file extensions being HTML, so let’s address the other issues one by one.

    First thing I’d suggest is to turn off the HTML validation, that will get rid of the “invalid location for TABLE” type errors everywhere. We ship the validator off by default since most web applications do not have valid HTML at design time (most of it is generated on the fly from includes or other frameworks).

    #236065 Reply

    I don’t mind turning off the HTML validation as a temporary measure, but I hope I don’t have to cripple one part of the desired functionality to get the others to work. When working in a jsp page, I would like to have the validation in case I mistype something (like forget a closing tag).

    Having said that, my largest need is being able to open .html files with the MyEclipse JSP Editor

    Thanks for your ongoing assistance in this!
    [/code]

    #236074 Reply

    Riyad Kalla
    Member

    Having said that, my largest need is being able to open .html files with the MyEclipse JSP Editor

    This should just work already, did you try the File Association changes and or right clicking and Open With? Or was the issue that the HTML editor is used EVEN THOUGH you used these measures?

    #236099 Reply

    Or was the issue that the HTML editor is used EVEN THOUGH you used these measures?

    That is exactly the issue. I already set the File Association and “right click”, “Open With”. The page still opens with the HTML Designer rather than the specified JSP Designer.

    I did the same thing but chose “MyEclipse XML Editor” and it DOES in fact use the XML editor. This leads me to believe that the problem lies within the JSP and/or HTML Designer.

    #236107 Reply

    Riyad Kalla
    Member

    Sorry for the previous confusion, we are on the same page now and I have reproduce the issue, I am filing it for investigation.

    #236117 Reply

    Thank you very much for your help on this issue.

    Additionally, regarding the second item, will it be possible to have HTML validation on JSP fragments? I am able to get rid of the validation error by turning off HTML validation for the project, but the validation is an excellent feature to have when I am using properly formed segments of HTML code (and wish to ensure it remains so!), for example having only the following in my jsp fragment:

    <div>Howdy</div>

    shouldn’t cause validation errors.

    Thanks again!

    #236120 Reply

    Riyad Kalla
    Member

    will it be possible to have HTML validation on JSP fragments?

    Not any time soon, the HTML validator is 4.01 strict, that means anything that isn’t a nicely formatted fully-standalone page won’t pass muster, which fragments definately are not.

    I think what you are asking for is a well-formed validator, we don’t ship one, just a hugely complex HTML validator 🙂

    #236123 Reply

    Alrighty, thanks for the prompt reply and thanks for all of your help. Where should I watch to find out when the other item is fixed?

Viewing 11 posts - 1 through 11 (of 11 total)
Reply To: JSPEditor Problems(open .html and false jsp validation errs)

You must be logged in to post in the forum log in