Out.println not recognized

I want to select a value from my databases and to print it on the screen, but it doesn't recognize my out. println and I don't understand why.
I have a class that extend another class which extends HttpServlet.
The code is the following:
@WebServlet(name = "vizualizare_denumire", urlPatterns = {"/vizualizare_denumire"})
public class vizualizare_denumire extends vizualizare_statiuni {
String den_s,criteriu;
protected void actualizare_db(String criteriu,String sql_statement){
try{
String dbURL="jdbc:odbc:statiuni";
String user="";
String pass="";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection(dbURL,user,pass);
Statement s=c.createStatement();
ResultSet r=s.executeQuery(sql_statement);
criteriu=r.getString(1);
out.println(criteriu);
s.close();
catch(ClassNotFoundException a){}
catch(SQLException a){}
@Override
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet vizualizare_denumire</title>");
out.println("</head>");
out.println("<body>");
den_s=request.getParameter("den_s");
sql_statement="select caracter from statiune where den_s="+den_s;
actualizare_db("caracter",sql_statement);
out.println("</body>");
out.println("</html>");
} finally {           
out.close();
Can someone help me??
Edited by: 900482 on Dec 3, 2011 8:24 AM

900482 wrote:
it doesn't recognize my out. println and I don't understand why.Because there is no variable with the name in scope, i.e. your method doesn't have an out variable and you don't have a class level variable either.
You do have the out variable in your other method, processRequest. What you can do is pass it as a parameter to your actualizare_db method.

Similar Messages

  • System.out.println not working in Tomcat-4.1.x

    System.out.println not working in Tomcat-4.1.24. Any settings has to be enabled??? I am using tomcat for Solaris

    I think u can use ServletContext.log() to output info instased.

  • Why System.out.println not PrintStream.println ?

    Hi, just a beginner question
    I just wonder why should we use System.out.println, not PrintStream.println ?
    the field out in the System class is the instance of PrintStream class, isn't it?
    So why don't we just use the PrintStream class directly?
    Thanks..
    Edited by: riff_almighty on Oct 27, 2007 3:27 AM

    According to the api:
    A PrintStream adds functionality to another output stream, namely the ability to print representations of various data values conveniently. Two other features are provided as well. Unlike other output streams, a PrintStream never throws an IOException; instead, exceptional situations merely set an internal flag that can be tested via the checkError method. Optionally, a PrintStream can be created so as to flush automatically; this means that the flush method is automatically invoked after a byte array is written, one of the println methods is invoked, or a newline character or byte ('\n') is written.
    So there is nowhere mentioned about the PrintStream associated with the user console. System.out is the one instance of PrintStream which is associated with the console...
    Also println() is not a static method and cant be called upon the class...
    Edited by: VijayBabu on Oct 27, 2007 12:51 AM

  • 32-bit JDK 7 System.out.println not working in IDE

    Hi folks,
    I have a 64-bit Windows 7 OS.
    Due to 3rd party library/jar dependencies, i had to install the 32-bit Java JDK 1.7 and Eclipse IDE.
    I also installed NetBeans.
    So i have a 64-bit OS and am running 32-bit Java JDK/JRE & IDEs.
    The problem I am having is that my program's System.out.println("...") statements are not outputting strings to either IDE debug console.
    Executing the compiled program from a command line/prompt produces the expected string output.
    The basic "Hello, World" program is enough to cause this behaviour to start occurring.
    I have not manually / intentionally changed any IDE-specific Debug Console or Windows environment settings.
    One caveat: This same environment has worked successfully in the past ?! Yes, this is one of those "..it worked last week & yesterday and today it isn't and i swear i didn't do anything..." issue.
    Thoughts ?

    Thanks for the reply.
    The 64-bit versions of Java & Eclipse were installed first.
    When i discovered I had to use the 32-bit versions, i un-installed the 64-bit ones & installed the 32-bits.
    Even after that initial un-install 64-bit/install 32-bit process, it was working.
    I have also been installing the Windows 7 64-bit OS updates when i am informed of them.
    I'm not sure if any of these would affect how the Eclipse / NetBeans IDEs behave.
    Behaviour has been inconsistent.
    Initially it was always working.
    But over the past several days, it has been working less and less.
    I don't have any large data structures.
    This isn't a large complicated program, couple hundred lines, so i highly doubt that i'm doing anything to the resources, but something has changed.
    The main project I am working on takes command line parameters, does some initial processing, produces output using System.out.printlns [SOP] then depending on the parameters, branches into 2 different processing paths, let's call them A & B. Each of these processing paths also use SOPs. When i run the program in the IDE going thru path A, sometimes the initial SOP statements will work and the SOP statements specific to path A will also work. If i immediately change the parameters to go thru path B & re-run it, not even the initial SOP statements before the branching decision work.
    I've tried doing System.flush()s too - no affect.
    I haven't tried the re-direction option to a file option you mentioned yet.
    It always works from a command prompt - that is telling me that the Java SOPs are working properly, correct ?
    Inside an Eclipse or NetBeans IDE, SOP output to the debug console is inconsistent.
    Running from a command prompt, the SOPs always work.
    It'd help to know if this an IDE issue, a Java issue, a Windows 7 issue so i can narrow down where to try and correct the situation.
    I have a Windows XP VM set up, i'll try running the program there and see if there's a difference.
    Thanks for your reply.

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

  • Help: What can make "System.out.println" not displaying anything?

    Hello,
    We have Portal 10g.
    I have noticed a pb on the interpretation of existing JSP pages.
    I simplified the code... and I noticed that even this command doesn't work :
    <%
    System.out.println("Hello World");
    %>
    Any idea ?
    Is there any security ? permission I should get ?
    JSP works fine on our old 8i environment ...
    Thanks in advance for your help.
    Olivier

    Olivier,
    between 8i and 10g are aeons of time (for computer technology). As far as I recall, in 8i came with a Apache and JServ module. This supported Servlets and JSP through a special Oracle implementation. After that OC4J as a J2EE container for EJBs and Servlets/JSPs was introduced.
    Using JSPs with the database installation only is not advised anymore. You can use OC4J for that. But be aware that will require some changes in the configuration and deployment of JSPs.
    HTH,
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Out.println not works after connecting database

    Hi,
    I am not able to view the output after connecting the database. If i change the output bfr connect it is working fine.
    any idea?
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    import java.util.*;
    public class Login3 extends HttpServlet
    public void doGet(HttpServletRequest req ,HttpServletResponse res)
    throws IOException,ServletException
    Connection conn = null;
    Statement st;
    ResultSet rs1,rs2;
    Statement select = null;
    ResultSet result = null;
    try{
    ResourceBundle config = ResourceBundle.getBundle("config");
    String dbserver = config.getString("dbserver");
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    Class.forName("org.gjt.mm.mysql.Driver");
    conn = DriverManager.getConnection("jdbc:mysql://192.168.1.20/test?user=saravanan&password=123456");
    out.println("<html><body>hai</body></html>");
    }catch(Exception e){e.printStackTrace();}
    }

    hi,
    Thanks for ur reply. I didn't get any exception or error in the log files
    Regards,
    Saravanan

  • While syncing my ipod all songs and pictures were cleaned out of it and now it is not recognized by itunes.  Help!

    Whiling syncing my ipod all of my music and pictures were cleaned out and now my ipod is not recognized my itunes.  I have uninstalled and reinstalled itunes and it didn't help.  Any suggestions?

    What shows up on the iPod's display when you have it connected to your PC?  Have you tried resetting the iPod with it still connected?  To this, press and hold both the Select/Center and Menu buttons together long enough for the Apple logo to appear.
    Otherwise, try rebooting your PC, opening iTunes, and then reconnecting your iPod to a high powered USB 2.0 port.
    B-rock

  • TS1538 Device not recognized in iTunes for Windows  I wasted about 1.5 hours with Apple on this issue. It all started happening after I updated to the latest version of iTunes. I haven't been able to sync my iPhone 4 in 1 month and am freaking out about p

    Device not recognized in iTunes for Windows
    I wasted about 1.5 hours with Apple on this issue. It all started happening after I updated to the latest version of iTunes. I haven't been able to sync my iPhone 4 in 1 month and am freaking out about possibly losing my pictures, video, text messages and music.
    Windows XP user.
    Any help will be greatly appreciated.
    iPhone 4, iOS 5.1.1

    If might be helpful if you actually told us what the problem is.

  • My ipod 4 when i plug it to my pc Windows 7 had worked fine for 8 months then one day i plug it in and a message came USB device not recognized, i tried reset network settings and nothing called apple they did not know any help out there TX

    My ipod 4 when i plug it to my pc Windows 7 had worked fine for 8 months then one day i plug it in and a message came USB device not recognized, i tried reset network settings and nothing i did not install any software before this happend i called apple they did not know, any help out there TX

    Start here:
    iPhone, iPad, or iPod touch: Device not recognized in iTunes for Windows

  • When I send out mail from MS Outlook enterprise account in the office to my Mac at home they are received as "winmail.dat" files.  Even if I perform a "save as" to the correct file name the file format is still not recognized.  Why is this happening!?

    When I send out mail from MS Outlook enterprise account in the office to my Mac at home they are received as "winmail.dat" files.  Even if I perform a "save as" to the correct file name the file format is still not recognized.  Why is this happening!?

    http://www.joshjacob.com/mac-development/tnef.php

  • Tomcat Servlet: System.out.println in servlet not printing to catalina.out

    Hello friends ,
    When i m using System.out.println() in servlet its o/p should come in catalina.out but its not coming plz help me....one thing more can we replace exixting catalina.out file with new one...
    please Help me soon.
    Thanks

    go to[u] TOMCAT_DIR/config/server.xml.
    Open this xml file and find something like <Logger className="org.apache.catalina.logger.FileLogger"
                  prefix="catalina_log." suffix=".txt"
                  timestamp="true"/>and
    <Logger className="org.apache.catalina.logger.FileLogger"
                     directory="logs"  prefix="localhost_log." suffix=".txt"
                timestamp="true"/>You can change the log file name to another one.
    It's much better to use a logger tool like log4j (http://logging.apache.org/log4j/docs/download.html) then using a System.out.println()...
    hope that helps

  • 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

  • System.out.println does not print out anything

    I'm wonder why the dos mode does not print out the System.out.println.
    My code has:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class test extends HttpServlet {
       public void doGet(HttpServletRequest request,
       HttpServletResponse response) throws IOException,
       ServletException {
          System.out.println("Hello");
    The compilation is ok... but it does not display anything... how come?

    "System.out.print()" prints to the log file of the tomcat server. in order to print on the screen use JspWriter.
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class test extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response) throws IOException,
    ServletException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("Hello");
    //System.out.println("Hello");
    Hope this helps!

  • Windows PC suddenly not recognizing iPhone. Recognizes another iPhone just fine. USB works until operating system in PC (XP) loads. Any clues out there?

    Windows suddenly not recognizing iPhone, yet recognizes another iPhone fine (sees in iTunes, etc.) USB appears to be fine - passes electrical to iPhone until operating system (XP) boots, and then "disconnects". I've gone through all of Apples suggestions for troubleshooting - including msconfig. Same result - quick double "bong" tone and no connectivity to iTunes. Versions are all up-to-date.
    Any suggestions out there?

    How did you get the VMWare sync to work? I hate Apple at this point.

Maybe you are looking for

  • No CD or USB-boot on Satellite C850-Z19 - Only Win 8 boots up

    Hello! I just bought a Toshiba Satellite C850 - Z19 (Windows 8 is installed). Although I edited the BIOS for booting with CD and USB before the HD, my usual bootable Debian Lenny and Squeeze CDs (32 or 64bit version) do not boot, only Windows 8 final

  • How to load new photos onto Iphone without duplicating old photos?

    Hi There I use my IPhone to store all of my photos and want to update it actively every couple of weeks, i recently tried to add to the existing photos on my iphone but found that the photos that were on the phone to begin with are now all duplicated

  • Unable to use Mac OS X Install DVD

    My iMac came with Mac OS X Install DVD, but since I have upgraded to Mountain Lion through the Apple App Store and have made a bootable USB. So after formatting my HDD I'm unable to boot from the USB or the DVD. When prompt to select "where you want

  • A working application suddenly caused java.lang.NoClassDefFoundError

    I have a web application running on a resin server. Everything in my application worked fine at the beginning but suddenly I got java.lang.NoClassDefFoundError. I looked at the line number of the exception and found out that the classes causing java.

  • WRT54G ver 5.0 refuses ISP?

    I have a WRT54G ver 5.0. My ability to connect has become very inconsistent--90% of the time, I need to power down my ISP provided modem prior to connecting. My ISP ran a diagnostic & says that my wireless router is refusing the signal from the ISP.