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
Similar Messages
-
Difference between System.out.println() and out.println()
Hi,
In JSP we want to write the JNLP file contents to a ouput stream using "out.printl()".
The content of the JNLP file i am having in a String.
The "System.out.println()" is printing the correct JNLP file contents but "out.println()" writing wrong contents which are taken from Server JNLP file.
How to solve this problem?
Please guide me in this.
Thanks and Regards:
DheerajWhere is the "System.out.println()" running from? I don't think your problem has anything to do with the difference between System.out.println and out.println. Both methods print what is passed to them. It sounds like you are printing two different files because you are running in two different environments.
JSPs run on a server and only have access to files on the server or on a network the server is on. If you are trying to print a file on a user's system, JSP can't do it. -
System.out.println and out.println
Sir,
i wana know the diff between System.out.println() and println plz help in this regard. how they work in jsp .
thanksHi
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 -
System.out.println() and System.err.println()
Can any one tell me the difference between System.out.println()
and System.err.println() ?Can any one tell me the difference between
System.out.println() Sends the output to the 'stdout' stream
and System.err.println() ?sends the output to the 'stderr' stream.
http://en.wikipedia.org/wiki/Standard_input -
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.printlnThank 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! -
System.out.println and EJBs
Hi,
I'm trying to develop an application that has 2 main components:
1) A stateless session EJB, which is called by the container timer service periodically and makes some DB uptades.
2) A servlet which basically calls the create method in the EJB.
I've implemented a prototype of the app and the servlet code looks like this:
try {
Context context = new InitialContext();
MyClassLocalHome home = (MyClassLocalHome)PortableRemoteObject.narrow(
context.lookup("java:comp/env/ejb/MyClass"),
MyClassLocalHome.class);
System.out.println("Narrowed");
MyClassLocal timer;
// create a new instance
timer = home.create();
System.out.println("Created!");
In the ejbCreate() in MyClass callback, all I have is a System.out.println("ejbCreate() called") to show the method was called.
My problem is the even though the servlet code runs without errors and I can see the output in the application server's SystemOut.log, I can't find "ejbCreate() called" message. Am I looking in the wrong place? Am I doing something wrong?
Thanks in advance.
PedroHi Pedro,
You're not necessarily doing something wrong. Where are you actually invoking a business method on the Stateless Session bean? In the Stateless Session Bean lifecycle, the actual bean instance creation is not required to be linked to the Home.create() call. That's because Stateless Session bean instances have no client-specific state. The container can delay the bean instance creation until an actual business method is called. Only then would the bean instance's ejbCreate method be called.
--ken -
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.
ThanksI 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 -
System.out.println and log file
I am developing jsp on BEA Weblogic 613 on Solaris.
What if i run the following statement
System.out.println("Hello world");
I understand that Hello World will be printed to the server console. I do not
have access to this console. Is there any log file or temporary log file it gets
sent to? If not, is there anyway to redirect output from the console to someplace
else?
Thanks!
You can redirect console output for stdout on Solaris like so:
java weblogic.Server > consoleoutput.txt
then in a terminal window you can see whats going on with
tail -f consoleoutput.txt
Sam
Brian Schneider wrote:
> I am developing jsp on BEA Weblogic 613 on Solaris.
>
> What if i run the following statement
> System.out.println("Hello world");
>
> I understand that Hello World will be printed to the server console. I do not
> have access to this console. Is there any log file or temporary log file it gets
> sent to? If not, is there anyway to redirect output from the console to someplace
> else?
>
> Thanks!
-
Hi everyone,
I am only a new comer and know very little about Java. I will appreciate a lot if anyone teaches me what the difference between two method println and print is? Thank you so much.The PrintStream class defines a number of print() methods that ... print
things. System.out is a commonly used PrintStream.
The difference between the print(...) and println(...) methods is that the
second one prints a new line at the end. What it actually prints varies
from system to system: sometimes it will output a '\n' sometimes not.
There is a system property called line.separator that determines
how a new line is output. -
Using System.out.println
I am migrating to a Sun server using Iplanet 6. I was on a HP-UX 11.0 server using Iplanet 4.2. I am having problems with two things. First, to get debugging information we use System.out.println in our servlets and JSP's. To get the output, we would redirect our start script when starting the server to a file. The trouble is now there is no output when using System.out.println.
My second problem is request parameters. I do not always appear to get my request parameters in JSP's that use frames. The outer frameset uses request.getQueryString and then passes the query string to the two frames in the frameset. However, I do not appear to be doing that now.Instead of using System.out.println, try looking into the ServletContext.log method.
I hope this helps with your first question.
-Richard Burton -
System.out.println(STX +"HELLO"+ ETX) ; ???
I hava one question I tried to display String which is begins with a sign "STX - this is a sign 0x02 in Ascii Table and ended with "ETX - this is a sign 0x03 in Ascii Table" using System.out.println, and nothing,
console was empty. When I deleted STX and ETX i got HELLO. I have question where is a problem. If you know answer on my question please write it.
Thank you and Regards SebastianI hava one question I tried to display String which is
begins with a sign "STX - this is a sign 0x02 in Ascii
Table and ended with "ETX - this is a sign 0x03 in
Ascii Table" using System.out.println, and nothing,
console was empty. When I deleted STX and ETX i got
HELLO. I have question where is a problem. If you
know answer on my question please write it.
Thank you and Regards Sebastianhow do you define STX and ETX ?
either of these should be valid
public static final char STX = (char)0x02;
public static final char ETX = (char)0x03;or
public static final char STX = \u0002;
public static final char ETX = \u0003;if they still don't work, it may be because these two characters are unprintable -
System.out.println() Print to JFrame
I just wrote a rather large java application and now want to develop a GUI for it. I have never developed GUI and am trying to use the API's for help. Can anyone point me in the right direction: I am trying to take everything that is printed out with System.out.println() and print it inside a JFrame. Any help would be magnificent.
-AlexAdd a JTextArea to your frame, create a TextAreaOutputStream with it, and use System.setOut(...) to set System.ouot
* Created on Mar 13, 2005 by @author Tom Jacobs
package tjacobs;
import java.io.IOException;
import java.io.OutputStream;
import javax.swing.JTextArea;
import javax.swing.text.JTextComponent;
* TextAreaOutputStream creates an outputstream that will output to the
* given textarea. Useful in setting System.out
public class TextAreaOutputStream extends OutputStream {
public static final int DEFAULT_BUFFER_SIZE = 1;
JTextArea mText;
byte mBuf[];
int mLocation;
public TextAreaOutputStream(JTextArea component) {
this(component, DEFAULT_BUFFER_SIZE);
public TextAreaOutputStream(JTextArea component, int bufferSize) {
mText = component;
if (bufferSize < 1) bufferSize = 1;
mBuf = new byte[bufferSize];
mLocation = 0;
@Override
public void write(int arg0) throws IOException {
//System.err.println("arg = " + (char) arg0);
mBuf[mLocation++] = (byte)arg0;
if (mLocation == mBuf.length) {
flush();
public void flush() {
mText.append(new String(mBuf, 0, mLocation));
mLocation = 0;
try {
Thread.sleep(1);
catch (Exception ex) {}
} -
Problems with System.out.println()
I tried writing a simple 'Hello world'-program:
public class Test{
public static void main(String[] args){
System.out.println("Hello World!");
}//main()
}//Test
But the text wouldn't appear in the DOS-window. The only text that showed up was the standard 'Press any key to close the window'. The program compiled without any problems, but didn't work when I tried to run it.
Does anyone have any idea what's wrong?Are u sure , the main() class part is donecorrectly.
Becuse program will compile but not run without a
main() class.what do you mean by main() class???First of all main() is a method, not a class. The main() method the JRE recognizes and runs is the:
public static void main(String[] params)
If you don�t have exaclty those modifiers and receive an array of Strings parameter it will send you an runtime exception.
Your code compiles and runs fine, the problem isn�t really System.out.print() it is something with your configuration.
I have to rename the class to TestF. Here is the running:
C:\cJava>javac TestF.java
C:\cJava>java TestF
Hello World! -
Intercepting System.exit() and System.out.println() calls
hi there,
I have often problems when working with code that uses System.exit() and System.out.println() extensively, because it becomes difficult to debug.
Basically I do have wrappers for System.exit() (my own static exit function) and for System.out.println() (log4j).
Still not all programmers are using these methods; Probably the only way to enforce this is some kind of code warrior, but I was hoping to be able to intercept the two System.XXX calls (and throw an appropriate Exception). is this possible ??Why not simply make your own security manager andhandle checkExit() and checkWrite?
Does anyone have a simple example of this? Please?System.exit() can be intercepted using a security manager, but not System.out.xxx.
Here is a short example:
//set your security manager
static{
SecurityManager s = new OwnSecurityManager();
System.setSecurityManager(s);
//redirect the out stream
try{
PrintStream ps = new PrintStream(new FileOutputStream("output.txt"));
System.setOut(ps);
}catch(IOException ioe){
ioe.printStackTrace();
//some tests
System.out.println("Test");
System.exit(2);
//your security manager
class OwnSecurityManager extends SecurityManager{
public void checkExit(int code){
if(code > 0){
super.checkExit(code);
throw new SecurityException("Not allowed here->" + code);
public void checkRead(FileDescriptor fd){
public void checkRead(String file){
public void checkRead(String file, Object context){
public void checkPermission(Permission perm){
if(perm.getName().equals("exitVM")){
System.out.println("exitVM");
} -
System.out.println() problem
When I use operator + for concatenate the following Strings
md.getDriverName() + md.getDriverVersion()
as follow in a try block:
try {
con = DriverManager.getConnection(sourceURL,user,pass);
md = con.getMetaData();
System.out.println(md.getDriverName().+md.getDriverVersion());
when I have tried run java -cp postgresql.jar errors message appers :
Exception in thread "main" java.lang.NoClassDefFoundError: while resolving class: conx
at java.lang.VMClassLoader.transformException(java.lang.Class, java.lang.Throwable) (/usr/lib/libgcj.so.6.0.0)
at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.6.0.0)
at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.6.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.6.0.0)
at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
Caused by: java.lang.ClassNotFoundException: java.lang.StringBuilder not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:postgresql.jar,file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.6.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.6.0.0)
But when I have used netBeans IDE v 4.0 it works fine.
Might somebody help me for solve it.Caused by: java.lang.ClassNotFoundException: java.lang.StringBuilder not found in
gnu.gcj.runtime.SystemClassLoader{urls=[file:postgresql.jar,file:./],
As I noted in your other post, your computer is configured to use gnu.gcj, not Sun's Java - and it appears that gcj doesn't have the StringBuilder class; it was added to Sun Java in Java 5.
Maybe you are looking for
-
ComboBox inside an ItemRenderer keeps going back to initial selectedIndex
Hi, Thanks for taking a minute to help me solve this problem. I have the following component, what I want to do, is to save the selectedIndex on the data.selectedIndice variable. I have no trouble with that. The variable saves the correct new se
-
Spacing in NavigationSettings.xml
Hi all, I tried to modify the XML entries in order to define the width of the page columns. I added this entries in NavigationSettings.xml (101 is the ID of my PlugNav): <intPlumtreeDPTableSpacing101 value="4" /><intPlumtreeDPLeftWidth101 value="200"
-
Temp password send to different email address
have adobe id but have forgotten password. the email address is no longer valid. want to send temp password to different email address jan
-
The app that came on my iphone called "game center" i deleted it. How do I put it back on?
-
Hello, When I attempt to burn a dual-layer DVD, I get an error: "OSStatus Error = -5000" All searches I've conducted indicate that it has something to do with the way that permissions are set up: afpAccessDenied = -5000, /* Insufficient access privil