Re: Blank lines in xhtml generated from JSP again

Discussion in 'XML' started by Chris Smith, Jul 3, 2003.

  1. Chris Smith

    Chris Smith Guest

    Mikael Petterson wrote:
    > Having the same problem again ;-)
    >
    > I have a addmov.jsp page the redirects to retry.jsp when addmov.jsp fails.
    >
    > I was told(thanks to Chris Smith) I must watch out for carrige returns
    > after %> since a blank line will be produced in my xhtml ( god knows how
    > !?) so I could solve it by typing the following in a JSP file:
    > ---------------------------------------------------------------
    > <%@page import = "com.lightlabs.teaching.help.*"%><%
    > CoolFlixSession mySession=(CoolFlixSession)session.getAttribute("coolflix");
    > if(mySession!=null){
    > ---------------------------------------------------------------
    > No space between %><% and everything was fine.


    Good.

    > However now I have to add code to instanciate my Bean DomFileWriter and
    > that will be between like this:
    > %><jsp:useBean id="processForm"
    > class="se.coolflix.helpers.DomFileWriter" scope="request" />
    > .......
    > <%


    There's another newline between the end of the jsp:useBean tag and the
    beginning of the following content, and again directly before the
    opening delimiter for the scriptlet. Try changing that to:

    > %><jsp:useBean id="processForm"
    > class="se.coolflix.helpers.DomFileWriter" scope="request"
    > />.......<%


    > Question:
    >
    > 1. How shall I handle my <jsp:useBean>-tags to avoid blank lines in the
    > produced xhtml.


    Just don't put the extra EOL characters in your source, and they won't
    show up in the output either.

    > 2. Why does carriage return produce balnk lines in my produced output?
    >


    Because you put them there. All the JSP engine does is copy the source
    to the output... except for special JSP elements like scriptlets,
    standard actions, etc. Anything outside of such a JSP element in the
    source -- including the EOL characters that form your blank lines -- is
    just copied over.

    --
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Jul 3, 2003
    #1
    1. Advertising

  2. Hi,

    Thanks Chris!!! I think I am getting closer to solving the riddle with
    your assistance. Do I get you right when I do the following:

    Anything between tags <% %> can have new lines. However is it the same
    with <jsp: /> ? That is can I have new lines inbetween? Then I should
    type it in the following way (see below).

    Thanks again for sharing your time and professional experience.

    //Mikael Petterson

    *************************************************
    <%@page contentType="text/html" import =
    "com.lightlabs.teaching.help.*"%><jsp:useBean id="processForm"
    class="se.coolflix.helpers.DomFileWriter" scope="request"
    /><jsp:setProperty name="processForm" property="userid"
    /><jsp:setProperty name="processForm" property="title"
    /><jsp:setProperty name="processForm" property="created"
    /><jsp:setProperty name="processForm" property="country"
    /><jsp:setProperty name="processForm" property="genre"
    /><jsp:setProperty name="processForm" property="dfirstname"
    /><%
    CoolFlixSession mySession=(CoolFlixSession)session.getAttribute("coolflix");
    ***************************************************************

    Chris Smith wrote:
    > Mikael Petterson wrote:
    >
    >>Having the same problem again ;-)
    >>
    >>I have a addmov.jsp page the redirects to retry.jsp when addmov.jsp fails.
    >>
    >>I was told(thanks to Chris Smith) I must watch out for carrige returns
    >>after %> since a blank line will be produced in my xhtml ( god knows how
    >>!?) so I could solve it by typing the following in a JSP file:
    >>---------------------------------------------------------------
    >><%@page import = "com.lightlabs.teaching.help.*"%><%
    >>CoolFlixSession mySession=(CoolFlixSession)session.getAttribute("coolflix");
    >>if(mySession!=null){
    >>---------------------------------------------------------------
    >>No space between %><% and everything was fine.

    >
    >
    > Good.
    >
    >
    >>However now I have to add code to instanciate my Bean DomFileWriter and
    >>that will be between like this:
    >>%><jsp:useBean id="processForm"
    >>class="se.coolflix.helpers.DomFileWriter" scope="request" />
    >>.......
    >><%

    >
    >
    > There's another newline between the end of the jsp:useBean tag and the
    > beginning of the following content, and again directly before the
    > opening delimiter for the scriptlet. Try changing that to:
    >
    >
    >>%><jsp:useBean id="processForm"
    >>class="se.coolflix.helpers.DomFileWriter" scope="request"
    >>/>.......<%

    >
    >
    >>Question:
    >>
    >>1. How shall I handle my <jsp:useBean>-tags to avoid blank lines in the
    >>produced xhtml.

    >
    >
    > Just don't put the extra EOL characters in your source, and they won't
    > show up in the output either.
    >
    >
    >>2. Why does carriage return produce balnk lines in my produced output?
    >>

    >
    >
    > Because you put them there. All the JSP engine does is copy the source
    > to the output... except for special JSP elements like scriptlets,
    > standard actions, etc. Anything outside of such a JSP element in the
    > source -- including the EOL characters that form your blank lines -- is
    > just copied over.
    >
     
    Mikael Petterson, Jul 3, 2003
    #2
    1. Advertising

  3. Chris Smith

    Chris Smith Guest

    Mikael Petterson wrote:
    > Hi,
    >
    > Thanks Chris!!! I think I am getting closer to solving the riddle with
    > your assistance. Do I get you right when I do the following:
    >
    > Anything between tags <% %> can have new lines. However is it the same
    > with <jsp: /> ? That is can I have new lines inbetween?


    Right. Whitespace is ignore inside a standard action, the same way it's
    ignored inside a scriptlet.

    --
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Jul 4, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. che
    Replies:
    2
    Views:
    510
  2. Replies:
    1
    Views:
    565
    Andrea Desole
    Dec 14, 2005
  3. Replies:
    0
    Views:
    4,442
  4. RichardOnRails
    Replies:
    3
    Views:
    284
    Robert Klemme
    Mar 7, 2011
  5. Cah Sableng
    Replies:
    0
    Views:
    247
    Cah Sableng
    Apr 23, 2007
Loading...

Share This Page