1

The problem is that section mapping my footer.jsp and header.jsp is red in IntelliJ Idea, though everything works well. also I understand that I should have for both mentioned files extension *.jspf, not jsp, but I have no idea how to make them in Idea. My web.xml is below, the strings between < jsp-config > and < /jsp-config > are all red and commented: "element is not allowed here"

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
          http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
           version="3.0">
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <jsp-config>
        <jsp-property-group>
            <description>header and footer settings</description>
            <url-pattern>/WEB-INF/views/*</url-pattern>
            <url-pattern>/index.jsp</url-pattern>
            <include-prelude>/WEB-INF/jspf/header.jsp</include-prelude>
            <include-coda>/WEB-INF/jspf/footer.jsp</include-coda>
        </jsp-property-group>
    </jsp-config>
</web-app>
Battle_Slug
  • 2,055
  • 1
  • 34
  • 60
  • How did you import this .xml? Did it come from a different OS? – ylun.ca Mar 23 '14 at 15:27
  • It was created automatically with creating new project in Idea. I just modified it according to the examples in the internet to avoid repeating code in all files. – Battle_Slug Mar 23 '14 at 15:31
  • Can you include links to the examples? – ylun.ca Mar 23 '14 at 15:35
  • [Please see here](http://stackoverflow.com/questions/7619480/is-it-possible-to-add-jspf-files-to-a-jsp-page-without-using-jspinclude) but as I said, I don't know how to create *.jspf, and I am not sure whether my way is a mistake, or it's OK. – Battle_Slug Mar 23 '14 at 15:51
  • [those `.jsp` files will be inaccessible to the web application, you are doing it wrong](http://stackoverflow.com/questions/13186448/file-names-for-jsp-include-directive-to-avoid-compilation-of-them) –  Dec 31 '17 at 05:47

4 Answers4

2

I created new servlet, and after that for some reason IntelliJ stopped highlighting mentioned part red. I deem it as occasional bug.

Battle_Slug
  • 2,055
  • 1
  • 34
  • 60
  • 2
    It's not an occasional bug. IntelliJ seems to get confused if there are multiple local XSD's available for a given URL. See this for detailed insight: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206864415-Cannot-validate-3-0-web-xml-descriptor – Jaywalker Mar 17 '17 at 11:11
2

It is sometimes bugging out for me too, and the only reliable way that worked for me to get rid of it was by restarting Intellij (my version is 14.0.3).

Nestro
  • 29
  • 2
1

This link should help with understanding .jspf files: What is .jspf file extension? How to compile it?

That being said, it should be an issue of getting IntelliJ to recognize .jspf files. This should be an issue of going into the settings and associating .jspf with IntelliJ. Cheers.

Community
  • 1
  • 1
ylun.ca
  • 2,504
  • 7
  • 26
  • 47
  • Thank you for the link. I understand that I just need to make the *.jspf extension manually, instead of looking for special menu item in IntelliJ to create jspf. Nevertheless, I created new servlet, and after that for some reason IntelliJ stopped highlighting mentioned part red. I deem it as occasional bug. – Battle_Slug Mar 23 '14 at 16:11
  • 1
    Yea it did seem like a bug to me at first (which was why I asked if you were importing this from another OS). Similar occurrences have happened to me with `.java` files and importing from MAC OSX to Windows. – ylun.ca Mar 23 '14 at 16:16
-1

I meet the same problem, and I found out it is because that the project doesn't include the JavaEE library, you can open the project structure>Libraries add the JavaEE librarie.

Alan
  • 25
  • 1
  • 1
  • 4