Using System.out.println or System.err.println

Hi All,
I've a Web Dynpro project which uses a simple java helper class.
The java class has 'try catch' statements.
When I'm in 'catch' I want to display an error message on the screen.
I know that System.err.println writes the message in the defaultTrace.trc log file in the server but as a developer I don't always have access to the server.
Is there an option to display the error message on the screen with some kind of response object? (I cannot use wdComponentAPI.getMessageManager.reportSuccess in my helper class)
Thanks,
Omri

Hi Omri,
   It's not true that you cannot use the MessageManager in your helper java classes. Here's how you can do it:
1. Create a java class in the src directory of your project and in the same packeage as your project. I think you have already done this. Let's say the class is called HelperClass.
2. Declare a public variable of type com.sap.tc.webdynpro.progmodel.api.IWDMessageManager. Call it say, msgManager. The import will be added automatically.
3. In the wdDoInit() of your WD write something like:
HelperClass helperObj = new HelperClass();
helperObj.msgManager  = wdComponentAPI.getMessageManager();
4. Then when you catch the exception in your helper class, do a simple reportException().
Regards,
Satyajit.

Similar Messages

  • Using System.err.println() from within the classes of WAS ?

    hi,
    I am using admin.jar,a jar file which is being used by Web Application Server in my own class.
    I am referencing some of the classes from admin.jar from my class.
    I tried to print some trace statements,using System.err.println() from within the classes in admin.jar but they did not reflect in defaulttrace0.trc.
    I made these changes in the admin.jar being used by WAS.
    I restarted the server and even restarted the machine but without success.
    I want to know how to print System.out.println() statements from within the classes in admin.jar.
    Also, am i looking for these statements in the right file for eg. defaulttrace0.trc. or is it some other file that i need to look into.
    I need urgent help on this.
    Reward points assured.
    thanks a lot.
    Saurav

    thanks craig,
    ur answer has helped me a lot.but it didnt quite help me.
    nevertheless i am trying to set different levels of severity.
    Is there anything else that i can do.
    Also,i commented out a line of code today in one of the class DataSourceManagerImpl.java in sapj2eenginedeploy.jar
    for eg. temp.delete in it deploy method.Buth that line still executed.
    I m totally lost as to wht to do.
    I m trying to create a datasource from my application in WAS.For that i m using the WAS APIs.But its not working completely.
    I am using the above jar and its method createdatasource.
    I am callin it from my application's class.
    It creates a datasource and i can see it in JDBC Connector list in Visual Administrator.But it appears with red sign meaning its not started.When i start it from the tool then it starts.
    But in defaulttrace.trc file it shows an error "FileNotFindException". This happens,and i am very much sure, in the deploy() of DataSourceManagerImpl.java class of sapj2eenginedeploy.jar.
    i want to apply println inside this method so i may know where exactly i ma getting the error and get so more info so i may solve my problem.
    pls help me.
    its really urgent.
    thanks again
    saurav

  • Where the hell do the system.out.println s go ??

    I am using 9ifs 9.0.1 in windows accessing ifsservers through jsps.
    I am wondering where will the SOP 's be printed whil accessing the ifsserver through jsps 's.
    I guessed it was at the apachev jserv log files. I turned the log on and also checked all the flags - info, debug, etc.
    Even then i cudnt fing the SOP 's getting logged ...
    Can anyone give a clue...
    Thanx,
    RaviSankar

    Have a look at the $ORACLE_HOME/9ifs/log/Node.log file.
    (If you use system.err.println, you will find them in the $ORACLE_HOME/Apache/Apache/logs/error_log.)
    Hope this helps,
    Bob

  • 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

  • How do I redirect System.err msg on NT

    As you probably already know, when running a standard alone java program, say myapp.class, if one wants to redirect the System.out.println message, one might do this on NT dos prompt:
    java myapp > myout.txt
    In this case, all messages from System.out.println that suppose to print on the screen are redirected to be written into myout.txt.
    If your error messages are displayed using System.err.println, the same command does not save your message to the file redirected as above. Does anyone know how can I do some similar thing in the command line to redirect my error messages into a file?
    Thanks for help.
    Stan

    to redirect standard error on nt:
    java myapp 2> myout.txt

  • Servlet out.println() method!

    Hi,
    I've been developing servlets for a year now and have found it ridiculous to output the whole HTML page using numerous out.println() lines. I think for a problem so vastly faced, there should have been a solution long time back (other than JSP)
    Atleast something like a htmlOut() method which would be a variant of the println() method which did the following:
    1. Take the whole HTML page output syntax as argument in one go.
    2. Smart way to use escape characters by parsing the argument for non-end of line double quotes (")
    3. Even another method so that the HTML page could be written in a seperate file and the file could be the argument to the out method.
    I think these steps would enhance the usability of Servlets many folds!
    Tell me what you think!
    Ashish Tengshe

    You can write your own output stream with all that functionality and set it as the default output stream for System class
    see --
    http://java.sun.com/j2se/1.3/docs/api/java/lang/System.html#setOut(java.io.PrintStream)

  • System.err

    what is the perpose of 'err' reference variable in System class. and how to use it?

    System.out leads the output to the standard output stream (normally mapped to the console screen). System.err leads the output to the standard error stream (and, by default to the console, as well). The idea behind having these two is that the standard output should be used for regular program output, and standard error should be used for error messages.
    Both the streams can be redirected to different destinations. If it is desired to redirect the output to an output file and error messages to a different log file, than on UNIX it can be done as follows:
    java MyClass > output.log 2>error.log
    This causes the regular output (using System.out) to be stored in output.log and error messages (using System.err) to be stored in error.log.
    If you have put error messages in your program, but you don�t want to see them, the technique given below can be used to do it:
    Java MyClass 2> /null
    This redirects the System.err messages to /null, so no error messages appear on the screen, but the normal program output can still be seen.
    Once again, google is your friend!!
    regards,
    Manuel Leiria

  • How to embed html tags in out.println

    Hi,
    i have the following code in a function in java which passes the JspWriter object
    out.println("<table>");
              out.println("<tr>");
              out.println("<td>User Id</td>");
              out.println("<td>Pack Purchased </td>");
              out.println("<td>Sms Used</td>");
              out.println("<td>Sms Left</td>");
              out.println("<td>New User</td>");
    out.println("</tr></table>");is what i'm doing rite? plz help.

    Hi,
    i' having a problem with the following code.
    the web page isnt displaying anything. its just a blank page. please help
    public void calculateUserDetails(JspWriter out) throws IOException
              out.println("<table border=1>");
              out.print("<tr><td>User Id</td>");
              out.print("<td>Pack Purchased </td><td>Sms Used</td>");
              out.print("<td>Sms Left</td><td>New User</td>");
              out.print("</tr>");
              Enumeration objEnumKeys = hashAllDetails.keys();
              while(objEnumKeys.hasMoreElements())
                 String strHashKey = (String)     objEnumKeys.nextElement();
                 UserDetails objUserDetails = (UserDetails) hashAllDetails.get(strHashKey);
                 intBasicPacksTotalCount += objUserDetails.CountBasicPacks;
                 intAdvancedPacksTotalCount += objUserDetails.CountAdvancedPacks;
                 int intCurrentUserSoldSmsCount = getSoldSmsCountToUser(objUserDetails);
                 intTotalSoldSmsCount = intTotalSoldSmsCount + intCurrentUserSoldSmsCount;
                 int intCurrentUserUtilizedSmsCount = intCurrentUserSoldSmsCount - objUserDetails.SmsBalance;
                 intTotalUtilizedSmsCount += intCurrentUserUtilizedSmsCount;
                 intActivePacksCount += getUserActiveSMSPacksCount(objUserDetails, intCurrentUserUtilizedSmsCount);           
                 int intTotalCountPackPurchased = packPurchased(objUserDetails);
                out.print("<tr><td>");
                out.print(objUserDetails.UserId);
                out.print("</td><td>Rs.");
                out.print(intTotalCountPackPurchased);
                out.print("</td><td>");
                out.print(intCurrentUserUtilizedSmsCount);
                out.print("</td><td>");
                out.print(objUserDetails.SmsBalance);
                out.print("</td>");
                boolean newFlag=NewUser(objUserDetails);
                if(newFlag==true)
                     out.print("<td>Yes</td></tr>");
                else
                     out.print("<td>No</td></tr>");
               }               //End while
               out.println("</table>");
         }     

  • 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

  • System.err.println or System.out.println

    while(true)
    System.err.println("Exception");
    The above sentences will cause the memory usage always increaing, at the end it will run out of memory.
    Why?

    public class Test {
    public static void main(String [] args) {
    while(true) {
    System.err.println("Exception");
    This is the whole program. It is definately a infinite loop, but it doesn't matter. Anyone can test it by changing the string value. Also, you can monitor the memory usage. It is very different between "Exception" and other strings which don't include "Exception".
    I use the Jbuilder5 under NT 4.0.

  • 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.

  • 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.

  • 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.

Maybe you are looking for

  • My husband and I both have separate accounts but we would like to share music under icloud. is this possible?

    my husband and I both have separate accounts but we would like to share music under icloud. is this possible?

  • Where did my arrows go?

    The arrows and buttons on the top of my finder windows have disappeared! I don't know if I accidentally changed a setting or something but I can't figure out how to change it back. Does anyone know where they went or how to get them back? Thank you!

  • Suddenly unable to use car adaptor or other accesories / Error Message

    I have had an Alpine head unit in my car with the ipod connection for about a year and it has worked fine until recently. Now I get an error message on the ipod that reads, "The currently attached accessory is not supported by this ipod." I tried con

  • Create BI System in Portal

    Hi, I am trying to create BI system in EP 7 as a part of BI – EP integration. I have followed following steps: 1. Start the iView System Administration -> System Configuration -> System Landscape. 2. Choose New -> System from the portal catalog conte

  • WTK 2.5.1on Linux

    Hi I am migrating my development enviroment from windows to linux but I am finding some problems, here are three issues I have seem: 1 ======================= The scripts run.sh does not work to solve this I had to: 1. change permission chmod 755 2.