Thanks a lot Hans!

Does anybody know what this flipping Comma-Separated-Value format is exactly?!
because it does NOT work for me?

What I am doing wrong?  I though the syntax  was

     <line ::= > = <value> [ "," <value> ] *  '\n';
     <value > ::=  any character except for quote or double quote!!!

Does anybody have a Servlet example that does this CSV thing? Cheers

BTW: Here is my JSP

 <%@ taglib uri="/orataglib" prefix="ora"
 %><%@ taglib uri="/emistaglib" prefix="emis"
 %><%@ page import="com.ora.jsp.util.*"
 %><%@ page import="com.ora.jsp.sql.*"
 %><%@ page language="java" contentType="application/cvs"
 %>
<jsp:useBean id="detailBean"
        class="com.db.gdd3.emis.report.ReportDetailBean"
        scope="request"
 /><jsp:useBean id="sqlBean"
        class="com.db.gdd3.emis.sql.ExpressoSQLCommandBean"
        scope="request"

 />

Report Author "," <jsp:getProperty name="detailBean" property="title" /> ","
Report Date "," <jsp:getProperty name="detailBean" property="date" /> ","
Copyright "," <jsp:getProperty name="detailBean" property="copyright" /> ","
Remarks "," <jsp:getProperty name="detailBean" property="remarks" /> ","
Report URL "," <jsp:getProperty name="detailBean" property="url" /> ","

<ora:loop name="sqlBean" property="columnNameList"
        loopId="columnName" className="java.lang.String"
        ><%= columnName
        %> "," </ora:loop>

<ora:loop name="rowsetData" loopId="row" className="Row"
 ><ora:loop name="row" property="columns"
        loopId="col" className="Column"
        ><jsp:getProperty name="col" property="string"
        /> "," </ora:loop>
</ora:loop>


--
Peter Pilgrim
G.O.A.T
                    "the Greatest Of All Time"



---------------------------------------- Message History 
----------------------------------------


From: Hans Bergsten <[EMAIL PROTECTED]>@java.sun.com> on 30/01/2001 21:40 PST

Please respond to A mailing list about Java Server Pages specification and reference 
<[EMAIL PROTECTED]>

DELEGATED - Sent by:     A mailing list about Java Server Pages specification and 
[EMAIL PROTECTED]>


To:   [EMAIL PROTECTED]
cc:
Subject:  Re: How get a JSP to write CSV file?


Peter Pilgrim wrote:
>
> How do get a JSP to write a properly formatted CSV file?
> Is there a way to make JSP stop adding new lines or spaces?
> Can JSP pack spaces tightly between <% .. %> and <tag> ...</tag>?

JSP follows the lead from XML with regards to line feeds: they are
preserved but ignored.

So the trick is to make sure you don't add any line feeds in the
JSP page where you don't want them. In your sample, you have a
line feed character after all JSP directives and action elements.
When the JSP container processes the page, it consumes the JSP
elements but adds the line feed characters to the response.
By placing ending and starting the JSP elements on the same line,
you get rid of all of the unwanted line feeds:

  <%@ taglib uri="/orataglib"
  prefix="ora" %><%@ taglib uri="/emistaglib"
  prefix="emis" %><%@ page
  import="com.ora.jsp.util.*" %><%@ page
  import="com.ora.jsp.sql.*" %><%@ page language="java"
  contentType="application/vnd.ms-excel" %><jsp:useBean
  id="detailBean" class="com.db.gdd3.emis.report.ReportDetailBean"
  scope="request" /> ...

and so on for all JSP elements.

I describe this in Chapter 12 of my book, in relation to WML
since WML browsers are sometimes picky about this stuff.

> Conversely can JSP be to told print a new line directly
> ( java.io.PrintStream.println() )?

Any line feed in the JSP page is preserved, so just put a line
feed where you need it. In a custom action tag handler or a bean
that writes to the response, you can use JspWriter.newLine();


--<CUT>--


--

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorised copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to