Are JSP files valid in any HTML version?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shyamal Prasad

    Are JSP files valid in any HTML version?


    Hi,

    Is there anyway to write JSP files as valid HTML of any sort. What I
    want to know is if JSP files are some sort of valid XML with a DTD
    that will check contents. Perhaps JSP files are valid XHTML documents?

    Any pointers would be appreciated. Searching the web seems to be
    leading me nowhere quickly.

    Cheers!
    Shyamal
  • Gerard Oberle

    #2
    Re: Are JSP files valid in any HTML version?

    There is something in the JSP standard about an XML representation for
    JSP pages (see http://java.sun.com/products/jsp/download.html#specs),
    but JSP pages are NEITHER XML nor HTML. To illustrate why, consider
    the generation of an img tag with the name of the image file coming
    from a call to some method on some object:

    <img src="<%=picture .getFileName()% >" alt="generated picture">

    How could you write this substitution in well-formed xhtml?

    That said, I think the relevant question isn't so much whether JSP (or
    its competitors, ASP, PHP, ColdFusion, etc.) are valid html, xml or
    xhtml. It really is, can they be used to generate conforming valid
    xhtml and/or html. If that is relevant, then what you may want to do
    is carefully write your JSP so that it constructs a page which is both
    valid xhtml (and therefore valid xml) and at the same time, valid
    html. Go to the www.w3c.org site, and look up the specification for
    xhtml. There is a discussion in that document on how to write a page
    that fills this requirement. Of course, that discussion is based on a
    static view. You have to build a JSP whose output conforms to those
    guidelines.

    Cheers!
    - Jerry Oberle

    Comment

    • Ingo Pakleppa - ingo at kkeane dot com

      #3
      Re: Are JSP files valid in any HTML version?

      On Fri, 25 Jul 2003 20:05:24 -0700, Gerard Oberle wrote:
      [color=blue]
      > There is something in the JSP standard about an XML representation for
      > JSP pages (see http://java.sun.com/products/jsp/download.html#specs),
      > but JSP pages are NEITHER XML nor HTML. To illustrate why, consider the
      > generation of an img tag with the name of the image file coming from a
      > call to some method on some object:
      >
      > <img src="<%=picture .getFileName()% >" alt="generated picture">
      >
      > How could you write this substitution in well-formed xhtml?
      >
      > That said, I think the relevant question isn't so much whether JSP (or
      > its competitors, ASP, PHP, ColdFusion, etc.) are valid html, xml or
      > xhtml. It really is, can they be used to generate conforming valid
      > xhtml and/or html. If that is relevant, then what you may want to do is
      > carefully write your JSP so that it constructs a page which is both
      > valid xhtml (and therefore valid xml) and at the same time, valid html.
      > Go to the www.w3c.org site, and look up the specification for xhtml.
      > There is a discussion in that document on how to write a page that fills
      > this requirement. Of course, that discussion is based on a static view.
      > You have to build a JSP whose output conforms to those guidelines.[/color]

      Excellent advice. I just want to add the recommendation to submit the HTML
      generated by the JSP to http://validator.w3c.org. Hint: download the Opera
      browser. If you use Opera to test your page, just bring up your JSP and
      hit Shift+Ctrl+V (on Windows or Linux; Opera on other operating systems
      might use different key combinations), and it will automatically go to
      this validator site.

      By the way, the validator site also has a link to a similar CSS validator.

      Do be aware that it is not always possible to write 100% W3C compliant
      HTML. One of the most troublesome problems is the marginwidth= and
      marginheight= attribute in the <body> tag; they are illegal in compliant
      HTML, but the only way to achieve the desired effect on some versions of
      IE and Netscape.

      --
      Keep American Families united! Support H.R. 539 and H.R. 832
      For more information, see http://www.kkeane.com/lobbyspousal-faq.shtml

      Comment

      • javadoc

        #4
        Re: Are JSP files valid in any HTML version?

        JSP files are NOT XML-compliant, so there is no DTD for validation. Even if
        you include your JSP scriptlets, expressions, and declarations in an
        XHTML-formatted file, the JSP tags themselves do not conform to XML syntax.
        The only way to get what you want is to use JSP bean tags only (like
        jsp:useBean), and put them in an XHTML-formatted file.

        "Shyamal Prasad" <shyamal.prasad @ericsson.com> wrote in message
        news:yzsznj2k06 d.fsf@ericsson. com...[color=blue]
        >
        > Hi,
        >
        > Is there anyway to write JSP files as valid HTML of any sort. What I
        > want to know is if JSP files are some sort of valid XML with a DTD
        > that will check contents. Perhaps JSP files are valid XHTML documents?
        >
        > Any pointers would be appreciated. Searching the web seems to be
        > leading me nowhere quickly.
        >
        > Cheers!
        > Shyamal[/color]


        Comment

        • Shyamal Prasad

          #5
          Re: Are JSP files valid in any HTML version?

          "Jerry" == goberle <goberle@hotmai l.com> writes:

          Jerry> That said, I think the relevant question isn't so much
          Jerry> whether JSP (or its competitors, ASP, PHP, ColdFusion,
          Jerry> etc.) are valid html, xml or xhtml.

          Thanks to everyone for responses.

          Incidentally, the relevant question actually actually was about the
          possiblity of writing JSP files as DTD validated documents.

          I write my xml/html files with a DTD aware editor, and I love being
          able to point and click to add tags/attributes, and validate structure
          with simple keystrokes. I was hoping to be able to train my editor
          (xemacs with PSGML) to learn how to write JSP for Struts so I don't
          have to keep looking up all the struts tags and so on (a concept that
          works great, for example, with ant build files and plain old
          HTML/XHTML).

          As it turns out the answer seems to be pretty much that I can't do
          this even when writing JSP files in the XML format because of
          limitations when it comes to DTD validation with namespaces in
          use. Not being able to validate mark up is something I am not used
          to. So for now my ant build files invoke jasper and compile.....not
          quite what I want, but close.....;-)

          Cheers!
          Shyamal

          Comment

          Working...