6 Replies Latest reply on Aug 24, 2006 9:36 AM by mrohad

    JSP insted XHTMLS (DVD store example)

    mrohad

      I am trying to change and work with the DVD store example

      I would like to work with JSPs instead os XHTMLs , is it possible with seam?
      in the web.xml
      I removed/changed:

      removed -->
       <security-constraint>
       <display-name>Restrict XHTML Documents</display-name>
       <web-resource-collection>
       <web-resource-name>XHTML</web-resource-name>
       <url-pattern>*.xhtml</url-pattern>
       </web-resource-collection>
       <auth-constraint>
       <role-name>NONE</role-name>
       </auth-constraint>
       </security-constraint>
      
      changed-->
       <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.xhtml</param-value> <-- I changed to .jsp
       </context-param>
      
      
      


      I changed all the xhtml pages to jsp and also the links inside the pages

      while loading JSP file:

      <%@ page contentType="text/html; charset=Cp1255" %>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      
      <html>
       <head>
       <meta http-equiv="Content-Type" content="text/html; charset=Cp1255"/>
       <title></title>
       </head>
       <body>
       <f:view>
       <h:form>
       hello world
       </h:form>
       </f:view>
       </body>
      </html>
      


      I am getting exception:
      com.sun.facelets.FaceletException: Error Parsing /newfile.jsp: Error Traced[line: 1] The markup in the document preceding the root element must be well-formed.
       com.sun.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:234)
       com.sun.facelets.compiler.Compiler.compile(Compiler.java:104)
       com.sun.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:192)
       com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:141)
       com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:93)
       com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:503)
       com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:553)
       org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
       org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:97)
       org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
       org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
       org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


      is there anything else I need to change?

      Thanks

        • 1. Re: JSP insted XHTMLS (DVD store example)
          mzeijen

          Offcourse you can use JSP instead of XHTML. But what you are trying to do isn't that easy. The XHTML files that you are changing are facelet files (java server faces) and no jsp files. You can't simply rename some tags and everything works.

          There are a lot of examples with seam that use jsp instead of jsf (+ facelets) for example the registration example.

          • 2. Re: JSP insted XHTMLS (DVD store example)
            mrohad

            thanks but
            1) the nwFile.jsp I am trying to view is just a simple JSP file why does it try to parse it?

            2) why in some examples they used jsp(registreations,issues) and in some other(dvd) they used xhtml? what is better?

            • 3. Re: JSP insted XHTMLS (DVD store example)
              baz

              Hello,

              1) the nwFile.jsp I am trying to view is just a simple JSP file why does it try to parse it?

              This is because you are using https://facelets.dev.java.net/. This stiuff is parsing your pages and complains about well formdness.
              From your exception:
              ...must be well-formed.
               com.sun.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:234)
              

              You have 2 Options:
              1. delete facelets from your project
              2. Use well formed jspx files.That is an jsp format that is compatibel with xml.

              This has nothing to do with seam. seam supports xhtml as jsp as jspx.

              2) why in some examples they used jsp(registreations,issues) and in some other(dvd) they used xhtml? what is better?


              This is to show that seam supports it all. But the answer to the question: What is better? is up to you.:-)
              Ciao,
              Carsten



              • 4. Re: JSP insted XHTMLS (DVD store example)
                mzeijen

                I am also finding out what I want to use. For now I settled for jsf + facelets. According to a lot of developers it seems a very good choice. It solves a lot of problems if you only use jsp or jsp together with jsf.

                I also must say that I really like it. Sometimes it does some strange stuff but most of the time it is my own fault ;).

                • 5. Re: JSP insted XHTMLS (DVD store example)
                  raja05

                  Remove the FaceletViewHandler from your faces-config.xml. This will make the app use the default JsfViewHandlerImpl which doesnt do any of the strict XHTML Parsing

                  • 6. Re: JSP insted XHTMLS (DVD store example)
                    mrohad

                    ok , thanks!
                    do you know any jspx tutorial?
                    how can I import Java class in xhtml file/jsf?