How to insert new line character?

Hi all,
I have two lines to print.
out.println("Available number of columns="+cols);
out.println("Number of columns must be present=10");My problem is:
i want both the lines to be printed one below the other. But, it is displayed in one single line.....
Can anyone please tell me how to insert new line character?
I tried with \n, '\n' and \r\n but, in vain......
Thanks for your time.
Regards,
Ashvini

You should never use "\n" directly.
The line separator character is different on different operating systems.
And putting quotes around it in your string will make absolutely no difference in the JSP.
To find out what the line separator is you should use System.getProperty("line.separator");
The JSPWriter and PrintWriter classes will automatically use this property with a println statement, so a println will always finish with a line separator.
The issue here was that HTML by default ignores all whitespace.
The solutions provided
- use a <br> tag instead of a carriage return
- use <pre> tags, which tells the browser not to ignore whitespace. That can be troublesome in JSP which generates a lot of extraneous carriage returns into the code.
Cheers,
evnafets

Similar Messages

  • ADF: how to insert new line character in column of VO?

    Hi Everyone,
    Im using Jdev 11G.
    i have a VO with 5 columns displayed on the ADF page.(VO has total 8 columns)
    1 column is the combination of 3 columns. i concatenated the 3 columns and added new line character after each column chr(13).
    VO query is working very fine in Toad. the columnn displays each concatenated column value after a new line character but the same query is not working in ADF.
    The column which is concatenating 3 columns and has to display with new line character is not displaying new line character its just concatenating the 3 values and displaying it on the page.
    wat can be the solution for this in ADF?
    Thank you.

    Setting escape="false" will allow putting html <BR> in the column and it will display ok however if your table allows export to excel the <BR> gets exported and displays as text in your exported file. Also & will export as &amp; To prevent that, use your original text without the escape=false setting and insert LF or CR (10 or 13 character), then add inline style of white-space: pre-line; to column or to style class in your skin. That will cause all line feeds to wrap but will export to excel without mixing html in the export.
    http://www.w3schools.com/cssref/pr_text_white-space.asp
    Edited by: Don Kleppinger on Jan 14, 2013 4:06 PM

  • How to insert new line in the copied schema with transaction code PE01?

    Dear Experts,
             I have copied HKT0 to ZKT0 , i want to insert new line between  line 150 and line 160 in ZKT0, I don't know how to insert new line 160, who can tell me ?
             Looking forward to your reply.
    Best Regards,
    Merry

    Hi,
    1. Open your schema,
    2. In first colume "Line" select line where you want to add new line,
    3. Replace first value in the column field (that indicates number of line) with character I (means insert),
    4. Press enter
    The line will be added. The same way you can add lines to PCR.
    To delete use character D.
    Cheers

  • How to insert new line break in XSLT mapping

    Hi experts,
    I am doing file to mail scenario, i am sending the text file as an attachment using reciever mail adapter.
    I did everything, i can able to send the mail with text file attachment, but with in the file i got multiple rows, i need to put line break in XSLT mapping.
    I did use following statement but it is inserting small rectangle between the records, the records are not separating with new lines, all are in one line.
    <xsl:text>*#xA;</xsl:text>   
    note: in real coding replace * with &
    Can anyone suggest me how to insert new line in XSLT mapping.
    My XSLT mapping as look like:
    <?xml version='1.0'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:ns0="http://www.Coj.co.za/SapIsuToABSA/DirectDebitFile">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:variable name="break">&lt;br/&gt;</xsl:variable>
    <xsl:variable name="space"> </xsl:variable>
    <xsl:variable name="newline"><xsl:text></xsl:text></xsl:variable>
    <xsl:template match="/">
    <ns1:Mail xmlns:ns1="http://sap.com/xi/XI/Mail/30">
    <Subject>Please Check Attached Direct Debit File</Subject>
    <From>S@za</From>
    <To>P@za</To>
    <Content_Type>text/plain</Content_Type>
    <Content>
    <xsl:for-each select="MT_SapIsuToABSA_DirectDebitFile/DirectDebitRec/Body">
    <xsl:value-of select="Space1"/>
    <xsl:value-of select="Cust_AccNo"/>
    <xsl:value-of select="Reserve_1"/>
    <xsl:value-of select="Cust_Name"/>
    <xsl:value-of select="Cust_Name1"/>
    <xsl:value-of select="Cust_Bank_AccNo"/>
    <xsl:value-of select="Space2"/>
    <xsl:value-of select="Cust_Bank_BranchNo"/>
    <xsl:value-of select="Reserve_2"/>
    <xsl:value-of select="Space3"/>
    <xsl:value-of select="Cust_AccNo_1"/>
    <xsl:value-of select="Space4"/>
    <xsl:value-of select="Reserve_3"/>
    <xsl:value-of select="Deduction_Amnt"/>
    <xsl:value-of select="Space5"/>
    <xsl:value-of select="Reserve_4"/>
    <xsl:value-of select="Space6"/>
    <xsl:value-of select="Action_Date"/>
    <xsl:value-of select="Space7"/>
    <xsl:value-of select="Reserve_5"/>
    <xsl:text>*#xA;</xsl:text>   
    note: in real coding replace * with &
    </xsl:for-each>
    </Content>
      </ns1:Mail>
      </xsl:template>
      </xsl:stylesheet>
    Kind regards,
    Praveen

    Hi,
    I think <xsl:text>#xa;</xsl:text> should do the trick, but depending on which OS (ux or win), the "new line" chars sequence is different (win would require a CRLF like <xsl:text>#xd;*#xa;</xsl:text>)
    Chris
    -> &
    Edited by: Christophe PFERTZEL on Apr 14, 2010 2:16 PM

  • How to remove new line character from query output?

    Hi,
    How to remove new line character from query output?
    have tried select replace(column_name, CHR(10), ' ') from table_name.
    Edited by: GreenHorn on Sep 11, 2008 12:53 AM

    Please consider, that windows uses a sequence of chr13||chr(10) Unix uses only one character chr(10).
    The new line character(s) may be OS-dependent.
    You could consider both with:
    replace(replace(column_name, CHR(13)||CHR(10), ' '),CHR(10),' ')
    Hartmut
    Edited by: hartmutm on 11.09.2008 01:32

  • How to insert new line char while writing bytes into file

    Hello Sir,
    Is it possible to insert the new line character in set of String variables and stored them into bytearray ,then finally write into File?
    This is the sample code which i tried:
                 File f = new File(messagesDir,"msg" + msgnum + ".txt");
                 FileOutputStream fout = new FileOutputStream(f);
                    String fromString = "From:    "+msg.getFrom()+"\n";
                    String toString = "To:     "+msg.getTo()+"\n";
                    String dateString = "Sent:    "+msg.getDate()+"\n";
                      String msgString =msg.getBody()+"\n";
                    String finalString=fromString+toString+dateString+msgString;
                    byte[] msgBytes = finalString.getBytes();
                    fout.write(msgBytes);
                 fout.close();in the above code , i tried to add the new line as "\n" in end of each string. but when i look into the generated files msg1.txt , it contains some junk char [] .
    please provide me the help
    regards
    venki

    but it has still shown the the junk char, its not able
    to create the new line in the created file i am afraid
    how am i going to get the solution?:(Do not be afraid dear sir. You are obviously using a windows operating system or a mac operating system. On windows a newline is "\r\n" not '\n', and on a mac a newline is '\r', not '\n'. If you make that correction, dear sir, your program will work.
    However, there is a better way. First, you probably want to buffer your output if you are going to write more than one time to the file, which will make writing to the file more efficient. In addition, when you buffer your output, you can use the newLine() method of the BufferedWriter object to insert a newline. The newline will be appropriate for the operating system that the program is running on. Here is an example:
    File f = new File("C:/TestData/atest.txt");
    BufferedWriter out = new BufferedWriter(new FileWriter(f) );
    String fromString = "From: Jane";
    out.write(fromString);
    //Not written to the file until enough data accumulates.
    //The data is stored in a buffer until then.
    out.newLine();
    String toString = "To: Dick";
    out.write(toString);
    out.newLine();
    String dateString = "Sent: October 27, 2006";
    out.write(dateString);
    out.newLine();
    out.close(); 
    //Causes any unwritten data to be flushed from
    //the buffer and written to the file.

  • How to use new line character?

    Hi,
    i am getting string value like this :
    name john company
    test1 position director sal
    45000
    i am getting this value in a string.
    i want to display the value like below :
    name john
    company test1
    position director
    sal 45000
    how to proceed on this ? can we use new line character here ? how can we use that? pls suggest me on this.
    Regards,
    Pavani

    Hi Friend,
    you can use the split method of String. to split that string base on space.
    for Example
         String st = "Jeetendra Kumar Choudhary";
         String[] string = st.split(" ");
         for (int j = 0; j < string.length; j++) {
              System.out.println(string[j]);
    By this way you can get the each word separately and you can concatenate it again in single string.if you need it.
    Regards
    Jeetendra.

  • Need help in how to print new line character in unix using java

    Hi All,
    I use the printstream class to print some line in a text using java.
    here is the code:
       FileOutputStream out; // declare a file output object
            PrintStream p; // declare a print stream object
                    p.print("\t");
                    p.print(date);
                    p.print("\t\t");
                    p.print(RecCount);
                    p.println("\n");when i use this and output of this character in windows is
    date RecCount
    22-07-2007 23456
    when i use the same code in unix it shows the following output:
    date RecCount[]22-07-2007
    it wont accept the new line character could any one give me an idea to solve this problem.

    PrintStream has a println() method. Use that. Or System.getProperty("line.separator").
    Because a newline char doesn't necessarily specify a line break. It's system-dependent.

  • How to insert new line in a text file

    hi all,
    i wnat to know how can i insert a new line in a text file using java.
    for example i want the formate of the text like this
    1 2 3
    4 5 6
    until now i know only how to insert data but not new line.
    Thanks in advandce

    Hi you can put a new line in a text file using System.getProperty("line.separator"). This implementation will work for every OS.
    import java.io.*;
    class Demo{
    public static void main(String args[]) throws Exception {
    FileWriter fr = new FileWriter("FileDemo.txt");
         fr.write("AAAAAAAAAA");
    fr.write(System.getProperty("line.separator"));
    fr.write("AAAAAAAAAAA");
    fr.close();
    }

  • XSLT - inserting new line character

    Hi, hoping somebody could help me please.
    I'm attempting in 10g to convert a XML purchase-order with multiple detail lines to a CSV delimited output using an XSLT to undertake the transformation. Each line of the purchase-order, namely the header and each detail line must go on separate lines within the CSV file. This means each line must be clearly terminated with a CR-LF.
    While I can happily convert the XML purchase-order to CSV format, my experiments in inserting a CR-LF have failed, resulting in all lines collapsed onto one large line.
    According to various sources on the Net, inserting the following entry in my XSLT file should generate the new line that I'm looking for:
    <xsl:text>ampersand#xa;</xsl:text>(In the above code replace the text "ampersand" with an actual & - I'm unable to display the proper ampersand hash value xa as this HTML page renders it as newline character)
    However with no success.
    The sample program below shows the conversion process. Anybody any idea on why I'm not seeing the output with new lines?
    Your help appreciated.
    CM.
    DECLARE
    v_xml XMLType;
    v_xml2 XMLTYPe;
    v_xslt XMLType;
    BEGIN
    v_xml := XMLType(
    '<?xml version="1.0" encoding="UTF-8"?>
    <PurchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.xxxx.com.au/schemas/gatewayPurchaseOrder.xsd gatewayPurchaseOrder.xsd"
    xmlns="http://www.xxxx.com.au/schemas/gatewayPurchaseOrder.xsd">
    <Header>
    <GatewayPurchaseOrderNo>1234</GatewayPurchaseOrderNo>
    <PharmacyReference>2345</PharmacyReference>
    </Header>
    <Detail>
    <ProductNo>9876</ProductNo>
    <APNNo>7654</APNNo>
    </Detail>
    <Detail>
    <ProductNo>8888</ProductNo>
    <APNNo>7777</APNNo>
    </Detail>
    </PurchaseOrder>');
    v_xslt := XMLType(
    '<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.xxxx.com.au/schemas/gatewayPurchaseOrder.xsd">
    <xsl:output method="text"/>
    <xsl:template match="/PurchaseOrder/Header">
    <xsl:value-of select="normalize-space(GatewayPurchaseOrderNo)"/>,<xsl:value-of select="normalize-space(PharmacyReference)"/>
    <xsl:text>ampersand #xa;</xsl:text>
    </xsl:template>
    <xsl:template match="/PurchaseOrder/Detail">
    <xsl:value-of select="normalize-space(ProductNo)"/>,<xsl:value-of select="normalize-space(APNNo)"/>
    <xsl:text>ampersand#xa;</xsl:text>
    </xsl:template>
    </xsl:stylesheet>');
    v_xml2 := v_xml.transform(v_xslt);
    dbms_output.put_line(v_xml2.getclobval);
    END;(In the above code replace the text "ampersand" with an actual & - I'm unable to display the proper ampersand hash value xa as this HTML page renders it as newline character)

    I don't know much about XSLT yet, but tickeled by the problem, after wandering over the internet and found stuff like this - http://forums.devshed.com/xml-programming-19/cannot-output-crlf-xslt-348042.html - I constructed the following...
    SQL> set serveroutput on size 50000
    SQL> DECLARE
       v_xml XMLType;
       v_xml2 XMLTYPe;
       v_xslt XMLType;
    BEGIN
       v_xml := XMLType(
          '<?xml version="1.0" encoding="UTF-8"?>
          <PurchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.xxxx.com.au/schemas/gatewayPurchaseOrder.xsd gatewayPurchaseOrder.xsd"
             xmlns="http://www.xxxx.com.au/schemas/gatewayPurchaseOrder.xsd">
             <Header>
                <GatewayPurchaseOrderNo>1234</GatewayPurchaseOrderNo>
                <PharmacyReference>2345</PharmacyReference>
             </Header>
             <Detail>
                <ProductNo>9876</ProductNo>
                <APNNo>7654</APNNo>
             </Detail>
             <Detail>
                <ProductNo>8888</ProductNo>
                <APNNo>7777</APNNo>
             </Detail>
          </PurchaseOrder>');
          v_xslt := XMLType(
             '<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                xmlns="http://www.xxxx.com.au/schemas/gatewayPurchaseOrder.xsd">
             <xsl:output method="text"/>
             <xsl:template match="/PurchaseOrder/Header">
                <xsl:value-of select="normalize-space(GatewayPurchaseOrderNo)"/>,<xsl:value-of select="normalize-space(PharmacyReference)"/>
                <xsl:text>AMPERSAND#xa0;AMPERSAND#xa;</xsl:text>
             </xsl:template>
             <xsl:template match="/PurchaseOrder/Detail">
                <xsl:value-of select="normalize-space(ProductNo)"/>,<xsl:value-of select="normalize-space(APNNo)"/>
                <xsl:text>AMPERSAND#xa0;AMPERSAND#xa;</xsl:text>
             </xsl:template>
             </xsl:stylesheet>');
       v_xml2 := v_xml.transform(v_xslt);
       dbms_output.put_line(v_xml2.getclobval);
    END;
    SQL>
    1234,2345
    9876,7654
    8888,7777
    PL/SQL procedure successfully completed.So first one space and then the CR-LF.
    Hope this helps?
    Message was edited by:
    mgralike

  • af:validateLongRange displaying message: How to insert 'new line' ?

    Hello,
    While using <af:validateLongRange> tag we need to display message in a well formatted way, we have to display each statement in a new line.For eg. : message as displayed by property 'messageDetailNotInRange' must come in three different new lines not as a continuous statement.I tried inserting '\n' escape sequence for new line, but it dint work.I tried spacing the statements but that also is not working out.
    Any idea how can we get this message displayed separately in three rows rather than in a continuous statement ?
    ++messageDetailNotInRange="You have entered a value more than is available. Value entered must be in the range of {2} to {3}.To delete this line, clear the value and click Delete"++
    +<af:validateLongRange id="xyz_VC1" minimum="1"+
    maximum="100"
    messageDetailNotInRange="You have entered a value more than is available. Value entered must be in the range of {2} to {3}.To delete this line, clear the value and click Delete"
    messageDetailMinimum="Minimum {0} allowed is {2}"
    messageDetailMaximum="Maximum {0} allowed is {2}"
    hintNotInRange="#{'xyz'}"/>

    Thx..Done that!! but dint get the desired result ,I put it as :-
    messageDetailNotInRange="You have entered a value more than is available.&lt;br&gt; Quantity entered must be in the range of {2} to {3}.&lt;br&gt; To delete this order line, clear the quantity and click DELETE."
    On corresponding page this message was displayed as :
    You have entered a value more than is available.<br> Quantity entered must be in the range of 1 to 100.<br> To delete this order line, clear the quantity and click DELETE.
    It dint insert line breaks in the message.Do i need to write it differently?
    Above html code is modified once i posted it, it has inserted line breaks here for the br tag i added , but in my actual .jsff page it did not . I can only see br tag displayed as part of message and no new line got inserted.
    I dont see an option to attach a file with the post so that I can show the code to you.
    Edited by: user13439821 on Aug 15, 2011 2:58 PM

  • How to insert new line in textarea

    I try programatiaclly to add for example three strings in <textarea>
    the final result should be something like this:
    --TEXTAREA TAG BEGIN
    line1
    line2
    line3
    --TEXTAREA TAG END
    I tried the hack described here;
    http://www.mail-archive.com/[email protected]/msg08294.html
    <c:set var="temp" value="one
    two"/>
    <c:set var="newline" value="${fn:substring(temp,4,5)}"/>after that I used it like this:
    <textarea>
      // forEach begin (write some output)
        <c:out value="${newline}"></c:out> //try to add new line
      // forEach end
    </textarea>Sorry about the wrong comment style, I'm just pointing out whta I expect as a result.
    I was surprised when I found out that "newline" value is "t" instead of special character "\n" or "\r". Anyway, I didn't receive the desired result.
    I use XML JSP files and UTF-8.
    Can anyone help me?

    I think I remember using a pre tag in between.
    <pre>
    // ur text area tags here.
    </pre>

  • How to write new line character to a file from textarea

    Hi ,
    I want to save the contents of textarea in a file.The textarea may contain new line characters,
    I am getting the contents from the textarea using getText() method but after writing the contents to the file
    it stores the entire text in a single line.But I want the text as it apperars in the textarea.
    Please provide me a good solution.
    -mani

    maybe this code samples are useful to your problem
    File datatext = new File(fileName);
    try {BufferedWriter writer =new BufferedWriter(new OutputStreamWriter(new FileOutputStream(datatext)));
    writer.write(.......);
    writer.newLine();
    writer.close();                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to add new line character \n but cant

    Hi,
    Im trying to add some text and seperate with a \n but its not
    doing it. Ive cut down my code to the below:
    <html>
    <head>
    <title>test</title>
    </head>
    <body>
    <script type="text/javascript">
    document.write('wer\nsd');
    </script>
    </body>
    </html>
    But it doesnt work...can anyone please help?
    Thanks

    Rudei wrote:
    > Hi,
    > Im trying to add some text and seperate with a \n but
    its not doing it. Ive
    > cut down my code to the below:
    >
    > <html>
    > <head>
    > <title>test</title>
    > </head>
    > <body>
    > <script type="text/javascript">
    > document.write('wer\nsd');
    > </script>
    > </body>
    > </html>
    >
    > But it doesnt work...can anyone please help?
    >
    > Thanks
    >
    this will work:
    document.write('wer'+'\n'+'sd');
    and this will *probably* work:
    document.write("wer\nsd");
    I just replaced single quotes with double quotes
    seb ( [email protected])
    http://webtrans1.com | high-end web
    design
    Downloads: Slide Show, Directory Browser, Mailing List

  • New Line Character in SQL Query

    Dear All,
    I am wondering if some one tell me how to insert new line character in the SQL Query Output for example I need out put in the following format. Every line on new line.
    The total count is:
    Registration: 1111
    Fees paid: 2222
    Admission Done: 3333
    Total:4000
    Many thanks

    Hi
    SQL> select
      2  'The total count is:
      3  Registration: 1111
      4  Fees paid: 2222
      5  Admission Done: 3333
      6  Total:4000
      7  ' dummy_txt from dual
      8  /
    DUMMY_TXT
    The total count is:
    Registration: 1111
    Fees paid: 2222
    Admission Done: 3333
    Total:4000
    SQL>
    SQL> select 'a'||chr(10)||'b' from dual;
    'A'
    a
    b
    SQL> T

Maybe you are looking for

  • How to wrap the text in column headers?

    Hi Friends, Can anyone please suggest how to wrap the text in column headers of a Java WebDynpro table? I believe that caption is the only UI element that a column header can have and it does not allow wrapping of the text. My original requirement is

  • Has anyone encountered this problem using auto sync?

    I am importing Canon 7D video files (1920X1080 at 30fps) and double system audio (.WAV files from a Nagra LB recorder).  I can drag any of the video clips into the project timeline to confirm it's size and framerate. When I use the Synchronize Clip c

  • Burning my songs to a cd

    I have a ipod mini and am trying to burn a cd but in my itunes library there a lot of exclamations, how can I solve the problem..thanks limewire is where i get my songs.

  • Understanding NVL: INVALID NUMBER in NVL Function

    Hi, The below query is a part of a cursor which takes in p_po_number as input with datatype same as segment1 of po_headers_all (varchar2(20)). The columns event_system_id1 to event_system_id4 are varchar2(240). In most cases p_po_number will be null

  • How do I put in a watermark onto my original work?

    how do I put in a watermark onto my original work?