Display newline using out.println

Can anyone tell me how can I put a new line using the out.println?
Because I wanna to display the record in the following format
which is
Username : xxx
UserID : xxx
Age : xxx
so on .....
Actually I wanna to do it in a table form(HTML)....
Can anyone suggest a better way to do it?

Put the stuff in table then:
<table>
<tr>
<td>username=<%=xyz%></td>
</tr>
<tr>
<td>pwd=<%=abc%></td>
</tr>
</table>
HTH,
J.Clancey

Similar Messages

  • In a JSP having a problem using out.println in method

    I am trying to update a field on a form using JAVASCRIPT generated by JSP. The following code works fine when in the main body of the code.
    The field tota on form mainform is updated based on the contents of strTest.
    out.println("<SCRIPT LANGUAGE='JavaScript'>")
    out.println("document.mainform.tota.value = " + strTest);
    out.println("document.mainform.tota.focus()");
    out.println("</SCRIPT>");
    But if you have 10 flds that you want updated, it would be nice NOT to have to use 40 lines of code to do it. I am trying to build a method that will accept a field name and some data to put in a form field. I started small and just wanted to update 1 fld using the method below:
    <%!
    //Declare method to update form fields
    void Update_Frm_Fld()
    out.println("<SCRIPT LANGUAGE='JavaScript'>")
    out.println("document.mainform.tota.value = " + strTest);
    out.println("document.mainform.tota.focus()");
    out.println("</SCRIPT>");
    %>
    I keep getting the error:
    Time_Entry_jsp.java:21: cannot resolve symbol
    symbol : variable out
    location: class org.apache.jsp.Time_Entry_jsp
    out.println("");
    ^
    Help.....

    try this:
    <%@ page import="java.io.*" %>
    <%!
    //Declare method to update form fields
    public void Update_Frm_Fld(HttpServletResponse response)
         throws ServletException, IOException{
              PrintWriter out=response.getWriter();
              out.println("<SCRIPT LANGUAGE='JavaScript'>");
              out.println("document.mainform.tota.value = "+1);
              out.println("document.mainform.tota.focus()");
              out.println("</SCRIPT>");
    %>and when you call the function use this:
    <%Update(response);%>

  • How to put tab for alignment using out.println?

    can anyone tell me how to put something like \t in out.println of JSP/

    out.println("<blockquote>your text</blockquote>");

  • Error on out.println inside declaration block

    I am trying to generate a html page from a method iside the jsp page. When I use out.println inside the declaration block (<%! ---- %>) I am getting following error : "Undefined variable or class name: out".
    I have tried using System.out.println, but that sends the output to the consol, and not the html page.
    What is the workaround for this ??
    Following is the test jsp page to illustrate the problem:
    <%@page language="java" %>
    <%@page import="wt.doc.*" %>
    <%@page import="wt.fc.*" %>
    <%@page import="wt.query.*" %>
    <jsp:useBean id="wtcontext" class="wt.httpgw.WTContextBean" scope="request"/>
    <jsp:setProperty name="wtcontext" property="request" value="<%=request%>"/>
    <html>
    <body>
    <%!
         public void prntest(){
              System.out.println("This will print the message only to console");
              out.println("This does not work");
    %>
    <h1>This is to test out.println function</h1>
    <%
    out.println("<br>This out.println statement works as expected<br>");
    %>
    <br>Now try this<br>
    <%prntest();%>
    </body>
    </html>

    Hai ,
    Here you are trying to access implict object "out" outside the Scriplets ie in function outside the init/service method .
    To get output from prntest() , you have pass a reference of JspWriter out to it .ie Your function should be
    <%!
    public void prntest(JspWriter out2){
    System.out.println("This will print the message only to console");
    out2.println("This does not work");
    %>
    <%prntest(out);%>
    This should now work .
    rakesh

  • What is the different  between System.out.println and out.print

    we move a project , jsp form to servlet to mysql db
    suddenly we get Chinese input problem
    on meantime only Thing I know is
    if( chineseName!=null) {
                           chineseName= new String( chineseName.getBytes("ISO-8859-1"),"UTF-8");
                         out.print(chineseName); //display Chinese
                          System.out.println("Hello1"+chineseName ); // display unread symbol
                 }I don't know why when we insert the value into db by StudentInsert(university_ID, surName, english_Name, chineseName, Address)
    the db get the value from System.out.println
    what setting decide my out put through System.out.println

    Thank you for the reply!
    after two days of search and guess.... I found out
    for Web application , which under glassfish , you need to put your jsp page under WEB-INF,
    other wise the server jsp turn your Chinese character that come from jsp request form to UTF8 symbol.
    not ideal how to change the configuration in glassfish yet!

  • Out.println()

    hi,
    It is possible to use out.println() in jsf backing bean mean in .java file if yes then how.

    I don't understand you. I still don't see a valid argument to use out.print() in a backing bean.
    At least, to output stuff from the bean in JSF, you should be using the h:outputText.

  • Syntax to pass parameter value to jsp using href in out.println

    Hi,
    I have the URL in the form as mentioned below:
    <a href="b2c/marketing/showDocDetail.jsp"> <%=doc_no%></a>
    I've created the hyperlink using href tag to the document number in the jsp using the below syntax.
    <% String a1 = "Document ";
           String a2 = "<a href=\"";
           String a3 = "marketing/showDocDetail.jsp\">";
           String a4 = doc_no;
           String a5 = "</a>";
    out.println(a1a2a3a4a5);
    %>
    When clicked the doc_no is passed to backend RFC and export parameter is retrieved to result.jsp where values along with doc_no are displayed.
    the value after clicked is not being passed to action.java class that does the retreival.
    Needful, backend class, bom, entry in config.xml is all maintained.
    Please help me out with the syntax to pass the parameter value into java class

    Hi Bharathi,
    try below.
    <%
           String a1 = "Document ";
           String a2 = "<a href=\"";
           String a3 = "marketing/showDocDetail.do?docNo=";
           String a4 = doc_no;
           String a5 = " \">";
           String a6 = doc_no;
           String a7 = "</a>";
    out.println(a1+a2+a3+a4+a5+a6+a7);
    %>
    I assume doc_no is java variable contains value of document number
    Now create action entry in config.xml file. Suppose "actionDoc.java" class process it.
    <action path="/marketing/showDocDetail" type="com.xyz.actions.actionDoc">
                   <forward name="success" path="/marketing/showDocDetail.jsp"/>
                   <forward name="error" path="/marketing/showDocDetail.jsp"/>
    </action>
    We are passing parameter docNo=doc_no to action class actionDoc.java in this class you can retrieve request parameter docNo from request object and then process it as you want.
    Let me know if you face any problem or error.
    eCommerce Developer
    Edited by: Ecommerce Developer on Nov 9, 2009 8:35 AM

  • Using System.out.println() in Scrapbook

    I am working through some tutorials on formatting numbers:
    http://docs.oracle.com/javase/tutorial/java/data/numberformat.html
    I am trying to use scrapbook. I can't seem to get the result I am wanting from System.out.println("Hello world")...I get null. To be specific I am trying to inspect:
    int i = 461012;
    System.out.format("The value of i is: %d%n", i)In this case I get:
    java.io.PrintStream@46b372
    Something tells me that System.out.format can't work in a scrapbook. Is there a way without writing a main and running as java?

    It seems that the format method returns the PrintStream (allowing you to chain method calls), and the return value is being printed.
    You would get the output you're looking for, if you use the String.format() method, since that'll return the formatted String.

  • Synchronized use of System.out.println()

    So I am again at the point of part of my program running ahead of itself out of the call stack and ruining the sequence or order of printing.
    I read that System.out.println() is synchronized so how may it be used to wait() until notified to continue and not ruin the output?

    jverd wrote:
    Always Learning wrote:
    YES SIR EJP! SIR! I thank you for the assistance because using only System.out and synchronizing worked beautifully.You said you're not using multiple threads. If this is true, then there's no reason to synchronize anything. The output will appear on System.out in exactly the order you send it there.
    Nos if only I could figure out dependencies to make it work with out and err.You have to stop and think about it for a minute. You know that when you call println() on either one of those two streams, the output may be buffered an not necessarily go immediately to the console. From that you can reason that if you call out.println() first, and then err.println(), that you could end up with err's buffer getting flushed first, and the output appearing on the console in a different order than that in which your code executed the calls.
    You are of course not surprised by this, given that you know that out and err are completely independent and just happen to end up at the same destination in this particular case.
    So, as a first guess, you might reasonably think that, since buffering is obviously the culprit here, calling flush() on each stream after each print() or println() call should eliminate the problem. In a multithreaded environment, this wouldn't be sufficient, of course, but it's a logical approach to try here.
    Another tidbit to make note of is that the System class has setOut() and setErr() calls. Since you're looking at out and err in the same console, you presumably don't care about the distinction between them (which makes me wonder why you're using them both in the first place, instead of just using one). If you're just going to mush them together into the same console anyway, then you can use setOut() or setErr() to make them the same stream, and things will be ordered as you expect.Very interesting Jverd and I think there may yet be life in what I would like to do. I did not know or was not immediately aware of these things. I will give it a try.
    To answer your question, I am using them both because, like logging, they are distinct in the Eclipse console (black for out and red for err). With your patch I just tried that distinction has faded but the output is sequenced the same so I do appreciate you noting this. Learn something new in Java each time I am doing a project. I considered using logging and putting errors in a window but I am not sure if I should do that; just not enough experience with it.
    Edited by: Always Learning on Oct 23, 2011 9:28 AM

  • Is it possible not to use System.out.println?

    Hi guyz,
    Can anyone tell me if there is a way not to use System.out.println but produce the output on the command prompt? I need to add two numbers which are accepted through the args(command prompt). I have to add them and show them on command prompt without using System.out.println. Can ANYONE HELP?

    Hi guyz,
    Can anyone tell me if there is a way not
    s a way not to use System.out.println but produce the
    output on the command prompt? I need to add two
    numbers which are accepted through the args(command
    prompt). I have to add them and show them on command
    prompt without using System.out.println. Can ANYONE
    HELP?Why can't you use System.out.println? What's the reason?
    Kaj

  • Why we use logger instead of System.out.println for debugging?

    Hi,
    why we use logger instead of System.out.println for debugging?
    Regard
    Sankar

    Ya Basha,
    good question....
    You can use the idoc method to transfer the data when you are having an interface between the sap system and the legacy system......
    All the times BDC is not preferable like take the case you developed on upload program with bdc after some days your company thought to go for upgrade the sap vesion from lower version to upper version... in that upgraded version the application may change like sequence of fields or screens at that time you previous bdc program will not work here so u have to develop a new program and and you have to take the things into consideration again...
    where as if you use bapi or idoc method it will support the upgradations...
    in the case of bdc you have to take the data into flat files.... and then upload it to sap system after all the validations done some times the data which is in the flat file is confidential so there is no security if u take such data in flat file any user can chang the data even though if u maintain the data in application server super user can change the data
    where is idoc is fully secured... you can easily establich the interface between the systems and once it is done you can transfer the data with full security because idoc r generated by a program... so there is no manual interaction.....
    I think i gave some useful answer to you
    ~~Guduri

  • How can I see whatever I print through System.out.println in my servlets when I use iplanet 4.1

    how can I see whatever I print through System.out.println in my servlets when I use iplanet 4.1

    Hi Nitin,
    Look out the below link, Hope this helps you.
    http://knowledgebase.iplanet.com/ikb/kb/articles/4235.html
    http://knowledgebase.iplanet.com/ikb/kb/articles/4790.html
    http://knowledgebase.iplanet.com/ikb/kb/articles/4699.html
    Regards,
    Dakshin.
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support.

  • Just bought an iMac and use iCloud.  calendar appointments on iMac are displayed 24 hours out of sync with the iPhone.  the iPad and macbook air pick up the same information correctly.  why is this?

    just bought an iMac and use iCloud.  calendar appointments on iMac are displayed 24 hours out of sync with the iPhone.  the iPad and macbook air pick up the same information correctly.  why is this?

    Hi smokeondz,
    Thanks for visiting Apple Support Communities.
    If your iCloud calendar entries are not displaying as expected, start with the troubleshooting steps in this article:
    iCloud: Troubleshooting iCloud Calendar
    http://support.apple.com/kb/ts3999
    Best Regards,
    Jeremy

  • How to replace System.out.println() using templates

    can you give the complete code for my problem which is given below.
    package include;
    public class P
    public static cout(int a)
    System.out.println( a);
    public static cout(int a,int b)
    System.out.println(a + b);
    // like this i need to write to accept parameters from the class. which is importing this package
    for some more examples
    public static cout(int a,String s)
    System.out.printn(a +s);
    and many more type i.e. all types of arrangements of datatypes
    the above is the package called "include" Now Iam Importing the package in the class Hello:
    import include.P;
    public class Hello
    public static void main(String args[])
    int i=10;
    float f=12.23;
    String s="hello";
    P.cout(i,f); //cout is the static method of package(include) class " P"
    P.cout("welcome",s)
    // like this I want to send any type and any no of arguments as the System.out.println()
    will handle.
    My aim is to replace the System.out.println() with P.cout() which can be achieve in my idea by calling the static method ( such as cout() ) which internally use System.out.println() method. I am facing problem in achieving this because we donot know which type and how many parameters he will send .
    My task is we have to create a method which will accept any no.of arguments and is of any type.I think this can be done BY USING TEMPLATES.
    So please understand my problem and send me reply.I am waiting for your reply.
    thank you.

    Although I am not sure why you are doing this, if you really are trying to code a replacement for System.out.println then:
    out is a PrintStream and the println methods of PrintStream have the following signatures:
    void println()
    Terminate the current line by writing the line separator string.
    void println(boolean x)
    Print a boolean and then terminate the line.
    void println(char x)
    Print a character and then terminate the line.
    void println(char[] x)
    Print an array of characters and then terminate the line.
    void println(double x)
    Print a double and then terminate the line.
    void println(float x)
    Print a float and then terminate the line.
    void println(int x)
    Print an integer and then terminate the line.
    void println(long x)
    Print a long and then terminate the line.
    void println(Object x)
    Print an Object and then terminate the line.
    void println(String x)
    Print a String and then terminate
    So you should only need to create corresponding methods.

  • Printing on chars on the same line using system.out.println

    i have the following string:
    String msg = "This is a message brought to you by one and the only";
    msg.toCharArray(); //converted to a char array.
    i've written a loop which goes through each of the char elements
    and puts it in it's own array:
    int i = 0;             
    while (i < msg.length)
                    char[] test = {msg};
    System.out.println(test);
    the problem is system out println prints out each of the elements on seperate lines is
    it possible to have them in one line to reform the original string?

    No exactly sure what you are trying to do. Does this
    help?
    String msg = "This is a message brought to you by one
    and the only";
    char[] test = msg.toCharArray();
    System.out.println(test);
    not really because i want to convert the string to a char array and then reform it in another char array and then i can choose which elements i want included and not to be so that it can be printed on the same line. I can do it the following way:
    char[] test = {test[0], test[1]]};
    but say i want all the letters containing the chracter T (and again i can use the above solution and select the elements from the string but i don't want to hardcode it, say the string changes etc) in the test array so then i thought of writing a loop:
    while (test[i] == 'T')
    char[] test2 = {test[i]};
    System.out.println(test);
    i++;
    but it puts each T in a new line...

Maybe you are looking for