Results 1 to 6 of 6

Thread: Jspx pages as views

  1. #1
    Join Date
    Jul 2005
    Location
    Oslo, Norway
    Posts
    14

    Default Jspx pages as views

    Hi,

    I was wondering if anybody had problems with using .jspx pages as views in Spring? I'm just using a really simple example to see if I can get it to work:

    information.jsp:
    Code:
    <%@ taglib prefix="c" uri="http&#58;//java.sun.com/jstl/core" %>
    <%@ taglib prefix="fmt" uri="http&#58;//java.sun.com/jstl/fmt" %>
    <%@ taglib prefix="str" uri="http&#58;//jakarta.apache.org/taglibs/string-1.1" %>
    <%@ taglib prefix="spring" uri="/spring" %>
    
    <html>
    <body>
    	<c&#58;out value="hello"/>
    </body>
    </html>
    information.jspx:
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <html 
     xmlns&#58;c="http&#58;//java.sun.com/jsp/jstl/core"
     xmlns&#58;dpe="urn&#58;jsptagdir&#58;/WEB-INF/tags/DPE/"
     xmlns&#58;jsp="http&#58;//java.sun.com/JSP/Page"
     xmlns="http&#58;//www.w3.org/1999/xhtml">
     
     <jsp&#58;directive.page 
          pageEncoding="ISO-8859-1" 
          contentType="text/html; ISO-8859-1" />
    
    	<c&#58;out value="hello"/>
    </html>
    To my knowledge, these two pages should give the same output. But they don't. The .jsp page gives the expected output ("hello"), but the .jspx page gives me an empty page, where I can find <c:out value="hello"/> in the source code. Btw, my url-pattern for the DispatcherServlet in web.xml is "*.htm".

    Is this expected behaviour from Spring's side? Has anyone seen something similar before and can help me out with a solution? My best bet so far is rewriting about twenty .jspx and.tagx files to "normal" jsp, something that doesn't seem too tempting.

  2. #2
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    I know someone that had similar issues but can't remember what the solution was. I notified him and hope he'll be answering soon...

    rgds,
    Alef Arendsen
    Alef Arendsen
    SpringSource
    http://www.springsource.com

  3. #3
    Join Date
    Jul 2005
    Location
    Oslo, Norway
    Posts
    14

    Default

    Thanks a lot, that would be real helpful.

  4. #4
    Join Date
    Aug 2005
    Posts
    8

    Default

    The fact that the page is in the source, and not rendered, tells me that the encoding type is probably wrong.

    I'm assuming you use Firefox, or at least have it installed. Grab the plugin liveHttpHeaders (http://livehttpheaders.mozdev.org/), and you can confirm or deny this theory.

    As for why the encoding type would be wrong when you're obviously setting it correctly in your JSP, I'm not sure. I'm very new to Spring, but I guess first I'd make sure they work ok without Spring in the picture, and then I'd start looking for places that Spring would set the encoding type.

    --James

  5. #5
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    How are you referencing the jspx file? Usually jspx are fragments which are included in another file? Do you have a view mapped which uses the jspx file directly?

    What does your web.xml look like?

  6. #6
    Join Date
    Feb 2005
    Location
    Munich
    Posts
    1

    Default jspx pages

    keibi

    I'm using .jspx pages for my views - your problem seems curiously familiar, but annolyingly I cannot remember the specific case or configuration that caused .jspx content not to render. I don't think this problem is related to Spring, rather your JSP/Servlet code or configuration.

    Firstly a basic question...what JSP version are you using? Is it JSP 2.0? The JSP syntax you used is for JSP 2.0.

    I put together a test page based on your .jspx example - this looks as follows:

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <html
     xmlns&#58;c="http&#58;//java.sun.com/jsp/jstl/core"
     xmlns&#58;jsp="http&#58;//java.sun.com/JSP/Page"
     xmlns="http&#58;//www.w3.org/1999/xhtml">
    
    	<jsp&#58;output doctype-root-element="html"
            doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" 
            doctype-system="http&#58;//www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
        <jsp&#58;directive.page contentType="text/html;charset=ISO-8859-1" />
        
     <body>
       <c&#58;out value="hello"/>
     </body>
     
    </html>

    Some things to note:

    1. This page uses a jsp:output tag to generate the DOCTYPE declaration for the page. This will help the browser identify how your page should will be rendered.

    2. I don't know if this is what you're intending, but your .jspx page is generating an XHTML document - in comparison, your .jsp page is generating an HTML page.

    Just to make your life more colourful, xhtml is not fully supported by all browsers (notably Internet Explorer...who'd have guessed!!!). I don't think that this is the root cause of your problem (the above example generates an XHTML page), but it adds another dimension to the problem.

    To generate a HTML DOCTYPE, use the following:

    a) 'xmlns="http://www.w3.org/1999/html"' instead of 'xmlns="http://www.w3.org/1999/xhtml"'

    and

    b) <jsp:output doctype-root-element="html"
    doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
    doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>

    3. Your .jspx page is missing a <body> tag - I guess that it didn't quite make it into your code example . If your target browser is very fussy, this might prevent anything from being displayed. (Again probably not the root cause of the problem.)


    Otherwise, you might want to check your web.xml file to make sure that you don't have a jsp-property-group element that explicitly tells the web container not to treat .jspx files as a JSP Document.

Similar Threads

  1. AbstractWizardController views
    By avp12 in forum Web
    Replies: 0
    Last Post: Mar 30th, 2005, 04:51 PM
  2. Multiple views and pages question
    By jwray in forum Swing
    Replies: 3
    Last Post: Feb 19th, 2005, 09:22 AM
  3. Multiple Pages
    By afida in forum Swing
    Replies: 12
    Last Post: Feb 16th, 2005, 08:42 AM
  4. Replies: 1
    Last Post: Feb 15th, 2005, 01:05 PM
  5. Newbie question on Pages and Views
    By ragnarwestad in forum Swing
    Replies: 8
    Last Post: Dec 13th, 2004, 10:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •