How can I show a System.out.println(""); into a JSP?

Is a simple doubt that would help me a lot to reach other thing that I wished reach with a JSP.
Thank you!!!

Hi!!!
Thank you to answer me......my question�is because�my problem is a little more complicated��let me tell you�.
My problem is that I wish to do some queries to a table of a Municipalities DB, I have read about that....and according with the exemples....my JSP...should be running and executing very well....but I haven�t had success with that...:(
My JSP file is:
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<!-- Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.-->
<head>
<title>Query of Municipalities</title>
</head>
<body bgcolor=#FFFFFF>
<font face="Helvetica">
<h1>
<font color=#DB1260>
Municipalities List
</font>
</h1>
<%@ page import="
weblogic.db.jdbc.*,
weblogic.html.*,
java.sql.*
" %>
<p>
<%
Connection conn = null;
try {
Class.forName("weblogic.jdbc.pool.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:weblogic:pool:DESAPool");
catch (Exception e) {
e.printStackTrace();
Statement stmt = conn.createStatement();
stmt.execute("select * from cat_municipio");
ResultSet rs = stmt.getResultSet();
while (rs.next()) {
System.out.println(rs.getInt("cve_municipio") + " - " + rs.getInt("cve_sepomex") + " - " + rs.getString("desc_municipio"));
stmt.close();
conn.close();
%>
<p>Please call Mary with any updates ASAP!
<p>
<font size=-1>Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
</font>
</font>
</body>
</html>
My result obtained is the following:
Municipalities List
Please call Mary with any updates ASAP!
Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
I don�t obtain nothing.....is like DB table were without information......but in reality the DB table has information.....and I can obtain it with the following JSP:
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<!-- Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.-->
<head>
<title>Query of Municipalities</title>
</head>
<body bgcolor=#FFFFFF>
<font face="Helvetica">
<h1>
<font color=#DB1260>
Municipalities List
</font>
</h1>
<%@ page import="
weblogic.db.jdbc.*,
weblogic.html.*,
java.sql.*
" %>
<p>
<%
Connection conn = null;
try {
Class.forName("weblogic.jdbc.pool.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:weblogic:pool:DESAPool");
// Fetch all records from the database in a TableDataSet
DataSet dSet = new TableDataSet(conn, "cat_municipio").fetchRecords();
TableElement tE = new TableElement(dSet);
tE.setBorder(1);
out.print(tE);
} catch (SQLException sqle) {
out.print("Sorry, the database is not available.");
out.print("Exception: " + sqle);
} catch (Exception e) {
out.print("Exception occured: " + e);
} finally {
if(conn != null)
try {
conn.close();
} catch(SQLException sqle) {}
%>
<p>Please call Mary with any updates ASAP!
<p>
<font size=-1>Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
</font>
</font>
</body>
</html>
and with this JSP I obtain all the following information:
Municipalities List
CVE_MUNICIPIO CVE_SEPOMEX DESC_MUNICIPIO
1 1 ACAJETE
2 2 ACATENO
3 3 ACATLAN
4 4 ACATZINGO
5 5 ACTEOPAN
Now...I need that the first JSP work very well, because...with that way...I can do queries and obtain the needed results for showing them in the Browser......
So, I already find out�.that�any string that I send to the browser with System.out.println(); isn�t showed�.so it is the reason of my question�..how I can see my results of a query using a loop (like a for, while) resolving it....I think my problem would be resolved.
So...I hope you understand me, and you could help me please...thanks.....
Mary
P.D. I also attempted with the following JSP...but the result is the same....I don�t obtain none result...
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<!-- Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.-->
<head>
<title>Query of Municipalities</title>
</head>
<body bgcolor=#FFFFFF>
<font face="Helvetica">
<h1>
<font color=#DB1260>
Municipalities List
</font>
</h1>
<%@ page import="
weblogic.db.jdbc.*,
weblogic.html.*,
java.sql.*
" %>
<p>
<%
Connection conn = null;
try {
Class.forName("weblogic.jdbc.pool.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:weblogic:pool:DESAPool");
catch (Exception e) {
e.printStackTrace();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select CVE_MUNICIPIO, CVE_SEPOMEX, DESC_MUNICIPIO from cat_municipio");
while (rs.next()) {
System.out.println(rs.getInt(1) + " - " + rs.getInt(2) + " - " + rs.getString(3));
rs.close();
stmt.close();
conn.close();
%>
<p>Please call Mary with any updates ASAP!
<p>
<font size=-1>Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
</font>
</font>
</body>
</html>

Similar Messages

  • How can i put a system.out.println into txt file

    i want to generate a txt file instead of system.out.println. for the output How can i do that and what code can i use for that??
    Edited by: crystalarun on Oct 14, 2007 11:40 AM

    suppose u ant output in "Output.txt"
    then code can be
    PrintStream out = new PrintStream(new FileOutputStream("Output.txt"));
    System.setOut(out)

  • System.out.println in Servlets/JSPs

    Hi,
    Which file and directory in JDeveloper 10g (10.1.3.0) on windows does the output of System.out.println get logged to? THanks in advance.
    regards,

    Goes to standard out, not a file. So if you're running the embedded server you will see it in your Embedded Server Console window. However, you should never be using system.out.println in a servlet/jsp. Instead use commons logging or log4j to get log messages.

  • HT1444 How can I upgrade my system 10.4 into a newer one or the latest I could get for my machine?

    I currently have Mac OS X V. 10.4.11 and there are some things I'm unable to use on my computer, Adobe flash player being one of them, so I figured why not upgrading my software into the latest I could get? However I have no clue how can this be done, or if it can be done?
    I'll appreciate any advice. Thank you.

    OS numbers and names
    OS X 10.4.x - Tiger
    OS X 10.5.x - Leopard
    OS X 10.6.x - Snow Leopard
    OS X 10.7.x - Lion
    OS X 10.8.x - Mountain Lion
    More about Macs
    The Apple History site has specifications for every Mac ever produced: http://www.apple-history.com/
    Upgrade to Leopard
    Those wishing to upgrade to Leopard should be aware that install disks can be expensive unless you contact Apple. Details: http://lowendmac.com/deals/best-os-x-leopard-prices.html Standard Leopard installers impose several hardware limitations including speed and RAM size but all these restrictions can be overcome. Google for details. Leopard works well at 500 MHz with 1 GB of RAM and many happy users have less than this.
    Upgrade beyond Leopard
    OSs beyond OS X 10.5.8 require an Intel processor. If in doubt check this: Click the apple at the top left of your screen and select 'About this Mac'. This will give you your OS number. Then click 'More Info' to see which processor you have. If it says PowerPC you cannot upgrade to Snow Leopard and above. If you have an Intel Mac it is well worth upgrading to Snow Leopard now and then considering other options after that. You can buy Snow Leopard here: http://store.apple.com/us/product/MC573Z/A
    Upgrade beyond Snow Leopard
    Information about upgrading Snow Leopard to Lion or Mountain Lion: http://store.apple.com/us/product/MD256Z/A
    Important
    Check that your Mac complies with any requirements. If you are not in the US you should use the Change Country link at the bottom of Apple pages.

  • System.out.println not showing up in the console

    Hi,
    I've some System.out.println statements in a static block in a Stateless
    Session Bean. I could not see these outputs in the Weblogic console. I'm
    using Weblogic 5.1 Any one faced this problem before? any help is
    appreciated.
    Thanks & Regards,
    Nithi.

    Take a look in the weblogic log files they might be redirecting std out.
    "Ryan LeCompte" <[email protected]> wrote:
    >
    Hello Nithi,
    I'm all out of ideas, unfortunately! However, check out the following
    links for
    some possible insight into the problem:
    http://groups.google.com/groups?q=System.out.println+5.1+WebLogic&start=60&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3d3df18e%40newsgroups.bea.com&rnum=69
    http://groups.google.com/groups?q=System.out.println+5.1+WebLogic&start=70&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3977417b%40newsgroups.bea.com&rnum=71
    http://groups.google.com/groups?q=System.out.println+5.1+WebLogic&start=200&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=3bc20346%241%40newsgroups.bea.com&rnum=209
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Nithi Rajan" <[email protected]> wrote:
    Hi Ryan,
    Thanks for your reply and sorry for the long silence. I was on vocation.
    Thre problem still remains.I'm very sure that the EJB
    is deployed by WebLogic as I'm able to call some methods.
    and I'm also calling EJB methods from Servlet. But my
    System.out.println statments work fine in the Servlet and
    not inside EJB (or anyother classes used by EJB).
    Any one has faced similar problems? BTW am using WebLogic 5.1
    Thanks in advance,
    Regards,
    Nithi.
    "Ryan LeCompte" <[email protected]> wrote in message
    news:[email protected]...
    Hello Nithi,
    I find it strange that your System.out.println statements are beingexecuted from
    within your servlets, but not in your stateless session bean. Are
    you
    positive
    that your EJB is being located and deployed by WebLogic? The statementsin
    your
    static { } block should be executed as soon as the WebLogic class
    loader
    finds
    the class and loads it into the JVM. I would suggest examining theconsole
    and
    try to determine if your EJB is in fact being deployed. Are you invokingmethods
    on the EJB inside of your servlets? Are you using any logging frameworkfrom within
    the EJBs which would redirect output to a file?
    Best regards,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Nithi Rajan" <[email protected]> wrote:
    Hi Ryan,
    Thanks for your reply. The setting in the weblogic.properties is
    as
    follows.
    weblogic.system.enableConsole=true
    So, that tells me that I should see all the System.out.printlns right?
    (Pleasecorrect me if I'm wrong). I can see all the System.out.println
    from
    my
    servletand not from the Session Bean (even if the System.out.println
    is
    outside
    static block).
    Please let me know your thoughts.
    Thanks & Regards,
    Nithi.
    "Ryan LeCompte" <[email protected]> wrote in message
    news:[email protected]...
    Hello Nithi,
    Are you sure that you don't have WebLogic configured to redirect
    all
    messages
    to a file instead of the console? Are you able to see yourSystem.out.println
    statements when placed within other methods of your stateless sessionbean? Please
    be a bit more specific.
    Thank you,
    Ryan LeCompte
    [email protected]
    http://www.louisiana.edu/~rml7669
    "Nithi Rajan" <[email protected]> wrote:
    Hi,
    I've some System.out.println statements in a static block in a
    Stateless
    Session Bean. I could not see these outputs in the Weblogic console.
    I'm
    using Weblogic 5.1 Any one faced this problem before? any helpis
    appreciated.
    Thanks & Regards,
    Nithi.

  • System.out.println and Network Adapter problem

    Hello,
    I am encountering a 2 strange problems. I have 2 oracle application server instances, one dev and one production.
    The first problem is when I type System.out.println in the JSP's i am able to see the output in both \opmn\logs\oc4jinstance. But the System.out.println in the java classes or bean show up only in development logs but not in production box.
    Is there a setting I am missing here?
    The second problem is on our development machine the application works fine, but as soon as we deploy the application on production I encounter:
    could not open new connection: Io exception: The Network Adapter could not establish the connection
    I have a class called DBUtils, which uses a 3rd party library to get connections from the connection pool as below. Using JSP I call the getConnection(). On my dev Oracle Application Server Instance it works fine, but on production I get the error. Can it be there is a setting that I am missing on the production box?
    When I use a JSP and connect to the database without using the DBUtil class. I can connect to the database fine. Also using the DBUtil class with production oracle IP address on the development machine lets me connect with no problem, but production machine does not let me.
    public class DBUtils {
    static ConnectionPoolBean pool;
    static {
    System.out.println("DBUtils() - before connection pool bean");
    pool = new ConnectionPoolBean();
    pool.setDriverClassName("oracle.jdbc.driver.OracleDriver");
    pool.setdbURL("jdbc:oracle:thin:@IPADDRESS:PORT:SID");
    pool.setUser("USERNAME");
    pool.setPassword("PASSWORD");
    pool.setInitialConnections(1);
    pool.setIncrement(1);
    pool.setSoftMaxConnections(40);
    public static Connection getConnection() throws SQLException {
    System.out.println("Getting Oracle Connection");
    return pool.getConnection();
    public static void returnConnection(Connection conn) throws SQLException {
    System.out.println("Returning Connection");
    pool.returnConnection(conn);
    Thanks for your help in advance.

    Hi
    System.out.println is a method of PrintStream in IO which is used to print the output on console in java progs.Here in jsp ,the o/p is printed on server's console window.But out.println is totally different as, out is implicit object derived from JspWriter and is used sly to PrinWriter 's object is used in servlets.It's work is to write upon Browser.
    System.out.println() is normally used in jsp for debugging purposes only.
    Ashish

  • Lost System.out.println statements.

    Hi
    I have few system.out.println in my jsp which i am using in my JSP provider channel. but when I look at the portal server's /var/opt/SUNWam/debug/desktop.debug file, none are there.. I looked at the web server's access and error logs too, but it is not there also.. can somebody tell me how do it get those ?? do we have any other mechanism to put debug logs ?

    By default the binary which web server runs is uxwdog which eats up System.out.println output. If you want to see the System.out.println then you need to change the product binary from the start script of the portal server instance.
    - Go to <portal-install-dir>/SUNWam/servers/https-<instance-name> and open the start script
    - Change the PRODUCT_BIN=uxwdog to PRODUCT_BIN=ns-httpd , save the file
    - Run the script ./start to start the portal server
    Note : with ns-httpd ON the server will not leave that shell, and in the same window/shell you will be able to see all your System.out.println statements. To close the server you have to kill the server process with "kill -9 pids" command
    Alternate way is to use api inside your application or jsp:
    <%@page import="com.sun.portal.providers.jsp.JSPProvider, com.sun.portal.providers.*, com.sun.portal.providers.containers.*, com.sun.portal.providers.context.*" %>
    <% JSPProvider p=(JSPProvider)pageContext.getAttribute("JSPProvider");
    ProviderContext pc = p.getProviderContext(); %>
    <%-- after that you can use these lines any where in your jsp --%>
    <%
    pc.debugError("your error msg");
    pc.debugMessage("your msg");
    pc.debugWarning("your warning msg");
    %>
    The perticular mgs will be shwon in /var/opt/SUNWam/debug/desktop.debug file as per your "debugLevel" parameter setting in /etc/opt/SUNWps/desktop/desktopconfig.properties file. By default the debugLevel is set to error so only pc.debugError("error msg") will be shown.
    Sanjeev

  • 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

  • Turn off System.out.println

    The nohup.out file is getting too big, how to turn off System.out.println without change any coding?
              

    java weblogic.Server > server.out 2>&1
              cheers
              mbg
              "Jen " <[email protected]> wrote in message
              news:[email protected]..
              >
              > How can I capture the System.out on windows?Thanks
              >
              > "Deyan D. Bektchiev" <[email protected]> wrote:
              > >just put the output to /dev/null on Unix/Linux or "nul" on Windows...
              > >
              > >Of course then the output is lost forever and you'll only have the
              > >Weblogic log files to look at any potential problems.
              > >
              > >--dejan
              > >
              > >java guy wrote:
              > >
              > >>The nohup.out file is getting too big, how to turn off
              System.out.println
              > >without change any coding?
              > >>
              > >>
              > >
              >
              

  • System.out.println and OAS

    Hello All,
    I have few System.out.println statements in my J2EE application which is running on OAS. I'm not sure where it is writing. I couldn't find anything in the server.log. Really appreciate any ideas.
    Thanks

    I know this is a couple of months old but it's a useful tip for anyone else having the same problem.
    You can't see the System.out.println statements in any logs through the administration web pages of the OAS. You have to go through the filesystem, which is annoying and in my opinion a massive error by Oracle. But never mind.
    The filepath is:
    %ORACLE_HOME%/opmn/logs/default_group~***~default_group~1.log
    replace *** with the name of your oc4j instance
    HTH
    Paul

  • Explain each term  System.out.println ( ) ?????

    Hi friends,
    I am new to java,
    can u explain about System
    out
    println
    I know System is class and what about out
    so class.class is possible ?
    can u explain each term
    plz
    it will help me in interview facing also.

    almost
    Out is a variable of PrintStream ( PrintStream out
    = new PrintStream() )I assume you meant the correct thing, but wrote the wrong one:
    out (note that it's lower case) is a public final static variable of the class System and it's of the type PrintStream.

  • 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 :Logging or System.out.println????

    Hi,
    Iam not able to see any System.out.println output in SAP? where exactly can i see it? any configuration required to enable logging? if so how?? please help

    Hi Sujesh,
    see https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/events/webinars/using logging and tracing on the sap web as java.pdf pages 12-17 and pages 22-24.
    Also see http://help.sap.com/saphelp_nw04/helpdata/en/e2/75a74046033913e10000000a155106/frameset.htm for portal specific logging issues.
    Hope it helps
    Detlev

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

  • How use system.out.println with a Java Swing Applet?

    Hi guys,
    I was just wondering what can I use to view output on the Java console with a Java Swing Applet?
    At the moment I'm using a JTextArea within the Applet for debugging but I want output to appear in the browser java console but system.out.println doesn't work.
    I'm viewing the Swing Applet on Netscape 4.7 browser.
    Any ideas?

    System.out.println()s work fine! I'm guessing that your problem is that you are looking at the wrong console window!
    You're using the Java Plug-in, right? On Windows, go to your Control Panel and double click "Java Plug-in". You should find a checkbox option to "Show Java Console" - make sure this is checked. Next time you fire up you JApplet, you should see a Java Console window popup.
    Hope this helps!

Maybe you are looking for

  • Image quality of imported PDF's

    I am running Motion 2.1 on a Mac Pro w/ an ATI 1900 X card and 2 Gb of ram (I doubt any of this info--aside from the software version--will help, but I figure it can't hurt). I am creating a project where a film reel runs across the screen. This is f

  • Refresh -BW connection is lost

    Report opens properly first time. when the user hits the refresh button Bw server connection is getting lost / breaking .I have to logon the report again. In the report I have an authorization level hierarchy in the selection parameter.I have created

  • Server not starting - Failed to Connect to hostname/3201

    Hi,    The Sneak Preview Version was working fine.. All of a sudden the server is not starting up.. It is throwing up the following error in the server0 log default.trc ##0#0#Error#1#/System/Server#Plain###Encomi: failed to connect to ganni/3201(Conn

  • My imac is 10.5.8 how can I update software, because I can't get into itunes anymore

    I am running 10.5.8 I am now booted out of iTunes because I need the latest iTunes version, but when i try to downlaod that, I am told my software version will not support my itunes version. I am stuck between a rock and a hard place. How can I move

  • Can't get to the JavaScript documentation

    I downloaded the Acrobat 9 SDK and unzipped the file. When I go to the Documentation folder and try and extract the help package from the zipped file it gets part way through then I get a message saying Windows Explorer is restarting. I get only part