Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Re: Blank lines in xhtml generated from JSP again

Reply
Thread Tools

Re: Blank lines in xhtml generated from JSP again

 
 
Chris Smith
Guest
Posts: n/a
 
      07-03-2003
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("c oolflix");
> 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
 
Reply With Quote
 
 
 
 
Mikael Petterson
Guest
Posts: n/a
 
      07-03-2003
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("c oolflix");
************************************************** *************

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("c oolflix");
>>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.
>


 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      07-04-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Blank lines generated by ERB - Can we prevent them? RichardOnRails Ruby 3 03-07-2011 12:31 PM
Preserve blank lines when add multiple lines of text to a cell Cah Sableng Javascript 0 04-23-2007 04:46 AM
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
(jsp) class loader not finding generated JSP class unixfreak0037@gmail.com Java 1 12-14-2005 09:35 AM
HttpSession gets generated again and again!! PLEASE HELP ME!!!! che Java 2 10-10-2005 10:20 PM



Advertisments