Sending "System.out" to a socket
Is it possibly to direct "System.out" to a socket. It can be done to a file with System.setOut(new PrintStream(new FileOutputStream(new File("/log.txt"))));
Reagards
Ulf
Is this OK?
import java.net.*;
import java.util.*;
import java.io.*;
public class Log
public static String host= "localhost";
public static Socket clientSocket=null;
public static PrintStream pstream=null;
public static void main(String [] args) throws Exception
clientSocket=new Socket(host,4444);
pstream=new PrintStream(clientSocket.getOutputStream(),true);
System.setOut(pstream);
clientSocket.close();
Similar Messages
-
How do I send an Image over a socket ?
I'm trying to get the output from my webcam and send that data out to a socket. Now the output from the webcam is running I'm just not sure how to send it out over the socket.
Server.java
import java.io.*;
import java.net.*;
public class Server {
public static void main(String args[]) {
ServerSocket serverSocket = null;
boolean listening = true;
try {
serverSocket = new ServerSocket(1354);
System.out.println("Listening for Connections...");
} catch (IOException drr) {
System.out.println("Error Listening :" + drr);
System.exit(-1);
try {
while(listening)
new ServerThread(serverSocket.accept()).start();
} catch (IOException er) {
System.out.println("Error Creating connection:" + er);
try {
serverSocket.close();
} catch (IOException err) {
System.out.println("Error Closing:" + err);
}When a connection is made it will start the webcam and send the image.
ServerThread.java
import java.net.*;
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import javax.media.*;
import javax.media.format.*;
import javax.media.util.*;
import javax.media.control.*;
import javax.media.protocol.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import com.sun.image.codec.jpeg.*;
public class ServerThread extends Thread {
public static Player player = null;
public CaptureDeviceInfo di = null;
public MediaLocator ml = null;
public JButton capture = null;
public Buffer buf = null;
public Image img = null;
public VideoFormat vf = null;
public BufferToImage btoi = null;
public ImagePanel imgpanel = null;
private Socket socket = null;
Image blah;
PrintWriter out = null;
public ServerThread(Socket socket) {
super("ServerThread");
this.socket = socket;
public void run() {
try {
out = new PrintWriter(socket.getOutputStream(), true);
imgpanel = new ImagePanel();
String str1 = "vfw:CompUSA PC Camera:0";
String str2 = "vfw:Microsoft WDM Image Capture (Win32):0";
di = CaptureDeviceManager.getDevice(str2);
ml = new MediaLocator("vfw://0");
try {
player = Manager.createRealizedPlayer(ml);
} catch (Exception npe) {
System.out.println("Player Exception:" + npe);
player.start();
Component comp;
if ((comp = player.getVisualComponent()) != null) {
// Grab a frame
FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
buf = fgc.grabFrame();
btoi = new BufferToImage((VideoFormat) buf.getFormat());
//Send the image over the socket
out.println(btoi);
} catch (IOException e) {
System.out.println("It bombed:" + e);
public static void playerclose() {
player.close();
player.deallocate();
class ImagePanel extends Panel {
public Image myimg = null;
public ImagePanel() {
public void setImage(Image img) {
this.myimg = img;
repaint();
public void paint(Graphics g) {
if (myimg != null) {
g.drawImage(myimg, 0, 0, this);
}The output I get from running the server is this:
BufferedImage@c9131c: type = 1 DirectColorModel: rmask=ff0000 gmask=ff00 bmask=ff amask=0 IntegerInterleavedRaster: width = 320 height = 240 #Bands = 3 xOff = 0 yOff = 0 dataOffset[0] 0
Now how can I turn this into an image If this output is correct?HUH?
I got the one to send the images over the network. I'm now trying to get the exact feed of the webcam and sending that over the network. This is alot more difficult to accomplish but I did see where I messed up my process of sending the images was just having to save the file then open it up put it in a byte array then send that over the network to the client. Once it was at the client i was able to re-construct it and throw it up in the frame. The only problem was lag. So this tells me it would be much more faster if instead of saving the file to send the client and having to reconstruct the image I should just send the webcam feed i used to make the image.
eh, I guess I didn't need any help.
Hey no offense or anything but you really have to learn how to spell better. -
Cannot send and read objects through sockets
I have these 4 classes to send objects through sockets. Message and Respond classes are just for
trials. I use their objects to send ıver the network. I do not get any compile time error or runtime error but
the code just does not send the objects. I used object input and output streams to send and read objects
in server (SOTServer) and in the client (SOTC) classes. When I execevute the server and client I can see
that the clients can connect to the server but they cannot send any objects allthough I wrote them inside the main method of client class. This code stops in the run() method but I could not find out why it
does do that. Run the program by creating 4 four classes.
Message.java
Respond.java
SOTC.java
SOTServer.java
Then execute server and then one or more clients to see what is going on.
Any ideas will be appreciated
thanks.
ASAP pls
//***********************************Message class**********************
import java.io.Serializable;
public class Message implements Serializable
private String chat;
private int client;
public Message(String s,int c)
client=c;
chat=s;
public Message()
client=0;
chat="aaaaa";
public int getClient()
return client;
public String getChat()
return chat;
//*******************************respond class*****************************
import java.io.Serializable;
public class Respond implements Serializable
private int toClient;
private String s;
public Respond()
public Respond(String s)
this.s=s;
public int gettoClient()
return toClient;
public String getMessage()
return s;
//***********************************SOTServer*********************
import java.io.*;
import java.net.*;
import java.util.Vector;
//private class
class ClientWorker extends Thread
private Socket client;
private ObjectInputStream objectinputstream;
private ObjectOutputStream objectoutputstream;
private SOTServer server;
ClientWorker(Socket socket, SOTServer ser)
client = socket;
server = ser;
System.out.println ("new client connected");
try
objectinputstream=new ObjectInputStream(client.getInputStream());
objectoutputstream=new ObjectOutputStream(client.getOutputStream());
catch(Exception e){}
public void sendToClient(Respond s)
try
objectoutputstream.writeObject(s);
objectoutputstream.flush();
catch(IOException e)
e.printStackTrace();
public void run()
do
Message fromClient;
try
fromClient =(Message) objectinputstream.readObject();
System.out.println (fromClient.getChat());
Respond r=new Respond();
server.sendMessageToAllClients(r);
System.out.println ("send all completed");
catch(ClassNotFoundException e){e.printStackTrace();}
catch(IOException ioexception1)
ioexception1.printStackTrace();
break;
Respond k=new Respond();
sendToClient(k);
}while(true);
public class SOTServer
ServerSocket server;
Vector clients;
public static void main(String args[]) throws IOException
SOTServer sotserver = new SOTServer();
sotserver.listenSocket();
SOTServer()
clients = new Vector();
System.out.println ("Server created");
public void sendMessageToAllClients(Respond str)
System.out.println ("sendToallclient");
ClientWorker client;
for (int i = 0; i < clients.size(); i++)
client = (ClientWorker) (clients.elementAt(i));
client.sendToClient(str);
public void listenSocket()
try
System.out.println ("listening socket");
server = new ServerSocket(4444, 6);
catch(IOException ioexception)
ioexception.printStackTrace();
do
try
ClientWorker clientworker=new ClientWorker(server.accept(), this);
clients.add(clientworker);
clientworker.start();
catch(IOException ioexception1)
ioexception1.printStackTrace();
while(true);
protected void finalize()
try
server.close();
catch(IOException ioexception)
ioexception.printStackTrace();
//*************************SOTC***(client class)*********************
import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;
class SOTC implements Runnable
private Socket socket;
private ObjectOutputStream output;
private ObjectInputStream input;
public void start()
try
socket= new Socket("127.0.0.1",4444);
input= new ObjectInputStream(socket.getInputStream());
output= new ObjectOutputStream(socket.getOutputStream());
catch(IOException e){e.printStackTrace();}
Thread outputThread= new Thread(this);
outputThread.start();
public void run()
try
do
Message m=new Message("sadfsa",0);
output.writeObject(m);
Respond fromServer=null;
fromServer=(Respond)input.readObject();
}while(true);
catch(NullPointerException e){run();}
catch(Exception e){e.printStackTrace();}
public SOTC()
start();
public void sendMessage(Message re)
try
Message k=new Message("sdasd",0);
output.writeObject(k);
output.flush();
catch(Exception ioexception)
ioexception.printStackTrace();
System.exit(-1);
public static void main(String args[])
SOTC sotclient = new SOTC();
try
System.out.println("client obje sonrasi main");
Message re=new Message("client ım ben mesaj bu da iste",0);
sotclient.sendMessage(re);
System.out.println ("client gonderdi mesaji");
catch(Exception e) {e.printStackTrace();}ObjectStreams send a few bytes at construct time. The OutputStream writes a header and the InputStram reads them. The InputStream constrcutor will not return until oit reads that header. Your code is probably hanging in the InputStream constrcutor. (try and verify that by getting a thread dump)
If that is your problem, tolution is easy, construct the OutputStreams first. -
How to Test, Inbound idoc ,with out the Sender System, using a Text File
Hi Guru's .
we wanted to test BLAORD03 inbound idoc (Message Type BLAORD).with out the SENDER SYSTEM.
on the same client.
we wanted to test this idoc with text file from our local machine.
Can anyone give us detail steps.like how to create File layout
with Segment name,and values for the fields.how to pass this file to the system.
Thanks in advance.Hi Aparna.
My requirement is to test the idoc with Inbound File.
Generate a file with the data entered through segments through we19 ,and use the same file for processing through we16.
when i am trying to do this syst complaing about
Partner Profile not available, and some times
port not available. and some times with
'No further processing defined'.
but i maintained part profiles and port perfectly.
Can you help me in testing with test 'File' port. -
Strange behaviour sending a text file over sockets
Hi !
Im not exactly new to Java. I discovered this behaviour when explaining to a junior.
I have a simple Server-Client architecture to send a text file. The server sends strings to client. The client checks for the string to become null, and never terminates !
Server.java
ServerSocket ss = new ServerSocket(25780);
Socket s = ss.accept();
PrintStream ps = new PrintStream(s.getOutputStream());
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
BufferedReader fis = new BufferedReader(
new InputStreamReader(
new FileInputStream(filename)));
while((read = fis.readLine()) != null){
ps.println(read);
client.java
Socket s = new Socket(IP,port);
PrintStream ps = new PrintStream(s.getOutputStream());
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
String read = new String();_
*while((read = br.readLine()) != null){*_
System.out.println(read);_
Can you tell me what mistake I'm making?Thank you so much for the reply !
All blocks are within try-catch. I didn't post the whole code since you would find it inconvenient !
I tried flushing the stream ! Still doesnt work !
I guess it might help to post the entire source:
CLIENT.JAVA
public static void main(String[] args) {
try{
System.out.println("Client");
int port = 25780;
String IP = new String("127.0.0.1");
Socket s = new Socket(IP,port);
PrintStream ps = new PrintStream(s.getOutputStream());
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
String command = new String();
String filename_to_recv = "from_ser.txt";
command = "GET "+filename_to_recv;
ps.println(command);
String received = new String();
String read;
while((read = br.readLine()) != null){
System.out.println(read);
String filename_to_send = "from_cli.txt";
System.out.println("recd data from server");
command = "PUT "+filename_to_send;
ps.println(command);
BufferedReader filereader = new BufferedReader(
new InputStreamReader(
new FileInputStream(filename_to_send)));
String to_send = new String();
while((to_send = filereader.readLine()) != null){
ps.println(to_send);
try{
Thread.sleep(2000);
} catch(Exception e){
System.out.println(""+e);
e.printStackTrace();
} catch(Exception e){
System.out.println(""+e);
e.printStackTrace();
SERVER.JAVA
public static void main(String[] args) {
try{
System.out.println("Server");
ServerSocket ss = new ServerSocket(25780);
Socket s = ss.accept();
PrintStream ps = new PrintStream(s.getOutputStream());
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
String command = br.readLine();
String filename = command.substring(command.indexOf(' ')+1);
File f = new File(filename);
BufferedReader fis = new BufferedReader(
new InputStreamReader(
new FileInputStream(filename)));
String read;
while((read = fis.readLine()) != null){
ps.println(read);
ps.flush();
System.out.println("waiting for client data");
command = br.readLine();
while((read = br.readLine()) != null){
System.out.println(read);
} catch(Exception e){
System.out.println(""+e);
e.printStackTrace();
} -
Send a picture file using sockets
Hi,
Could someone please tell me how I can send a picture file using sockets across a TCP/IP network? I have managed to do it by converting the file into a byte array and then sending it but I dont see the data back at the client when I recieve the file. I just see the byte array as having size 0 at client.
Byte array size is correct at client side.
//client code
System.out.println("Authenticating client");
localServer = InetAddress.getLocalHost();
AuthConnection = new Socket(localServer,8189);
out = new PrintWriter(AuthConnection.getOutputStream());
InputStream is = AuthConnection.getInputStream();
System.out.println(is.available());
byte[] store = new byte[is.available()];
is.read(store);
ImageIcon image = new ImageIcon(store);
JLabel background = new JLabel(image);
background.setBounds(0, 0, image.getIconWidth(), image.getIconHeight());
getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));
//extra code here
catch (UnknownHostException e) {
System.err.println("Don't know about host: LocalHost");
System.exit(1);
catch (IOException e) {
System.err.println("Couldn't get I/O for "
+ "the connection to: LocalHost");
System.exit(1);
//server code
DataOutputStream out = new DataOutputStream(incoming.getOutputStream());
FileInputStream fin = new FileInputStream("3trees.gif");
byte[] b = new byte[fin.available()];
int ret = fin.read(b);
out.write(b);i used OutputStream as
OutputStream out = incoming.getOutputStream(); and flushed the stream too.
But I still get the same output on the client side. I tried sending a string and it works , but I cant seem to be able to populate the byte array on the client side. It keeps showing zero. Please advise.
Thank you. -
How can I get my 2010 macbook pro to send signal out through the mini display port?
First, what you said is contradictory. You say "can't get a video signal", then say"the Mac wallpaper is broadcast, the mouse pointer is visible". "No video signal" means an absolutely black,blank screen. It sounds like you have plenty of signal.
I am supposing what you are seeing is actually a blank desktop, which is to be expected if your settings are such that you are extending the desktop, instead of mirroring it.
Within the preference panes is a setting that allows you to change this. Open System Preferences, click Displays, and then click Arrangement. You will see that you are extending the desktop. Change that setting. -
How to capture System.err and System.out in a method?
Is there some way to capture everything that is sent to System.err or System.out and have it instead go to e.g. a method as a String?
The reason I want to do is this: I am invoking some method from a class that sends output to System.err and System.out but while that method is run, I want everything that goes to System.out or System.err to instead go to a String buffer or a Swing Scroll Pane.
What is the easiest way to do this?I want everything that goes to System.out or System.err to instead go to a String buffer or a Swing Scroll Pane.Then maybe you should be searching (and then posting) in the Swing forum. Thats where I've seen this question asked and answered many times in the past.
-
RFC Adapter - Where to Register Rfc2XmbService (Sender System or XI ?)
Experts,
I have the following scenario:
R3 --> RFC_ADAPTER --> XI --> SOAP --> THIRD_PARTY
My specific question is, In which system do I need to register the Rfc2XmbService program. Is this done in the R3 system or in the XI system.
If it is done in the R3 system then where is it done cause there is no J2EE administration tool in R3.
Could someone explain exactly what this registration concept is.
Thanks and appreciate any help in advance.
- Ravi
--- I have figured this one out already. The program needs to be registered in XI and Not the sender system.
Thanks
Message was edited by: ravi kumarHello,
the Rfc2XmbService registers itself when you activate the RFC adapter in the Configuration but you can preallocate it through the Visual Admin.
Further by default are logging for sync calls not enabled, e.g. you don't see anything in SXMB_MONI.
Therefore go to SXMB_ADM and the Integration Configuration option and under the RUNTIME specific option create an entry for
RUNTIME LOGGING_SYNC 1 (0 is default).
Also make sure that the rfc adapter is activate in the AdapterFramework overview. On the target system call transaction SMGW and go to logged on clients to see if you see the Rfc2Xmb Service. Then in SM59 of the R/3 system you should have an entry pointing to the Rfc2Xmb service and a test should give you an idea if it works.
I'm doing R/3 4.6c -> XI 3.0 -> R/3 Enterprise about 20 BAPIs, no issue.
I hope this helps.
Stefan -
I use Keynote on iPad2. Video out via composite AV cable, audio out through earphone socket. If I plug into the earphone socket first, then plug in the AV cable - no sound. AV first, then earphone - sound. Anyone know why?
My daughter has had her Razr for about 9 months now. About two weeks ago she picked up her phone in the morning on her way to school when she noticed two cracks, both starting at the camera lens. One goes completely to the bottom and the other goes sharply to the side. She has never dropped it and me and my husband went over it with a fine tooth comb. We looked under a magnifying glass and could no find any reason for the glass to crack. Not one ding, scratch or bang. Our daughter really takes good care of her stuff, but we still wanted to make sure before we sent it in for repairs. Well we did and we got a reply from Motorola with a picture of the cracks saying this was customer abuse and that it is not covered under warranty. Even though they did not find any physical damage to back it up. Well I e-mailed them back and told them I did a little research and found pages of people having the same problems. Well I did not hear from them until I received a notice from Fed Ex that they were sending the phone back. NOT FIXED!!! I went to look up why and guess what there is no case open any more for the phone. It has been wiped clean. I put in the RMA # it comes back not found, I put in the ID #, the SN# and all comes back not found. Yet a day earlier all the info was there. I know there is a lot more people like me and all of you, but they just don't want to be bothered so they pay to have it fix, just to have it do it again. Unless they have found the problem and only fixing it on a customer pay only set up. I am furious and will not be recommending this phone to anyone. And to think I was considering this phone for my next up grade! NOT!!!!
-
System.out console output CP1252/CP850
I've been trying to write something to receive XML as 'messages' through a socket connection and, in order to see better what's being parsed, I've been writing the elements and data to System.out so I can see the values in the console window (this is Windows XP).
The problem I get is that when the client passes German characters such as '�' (o-umlaut), they don't get displayed correctly on the console window - the character that actually gets displayed is '�' (division sign?) - even though the correct value DOES (as far as I can tell) find its way into my Java String object.
I've investigated this a bit and I find that if I 'force' the output to use encoding 'Cp850' (OEM - Multilingual Latin I) then it works correctly (I do this by creating an OutputStreamWriter object with that encoding and based on System.out and then I create a BufferedWriter based on that OutputStreamWriter).
If, however, I explicitly use Cp1252 (ANSI - Latin I) then I get the original problem. I don't understand this because as far as I can tell, Cp1252 included the '�' character as code 246, which is the one I'm passing to it.
It also may (or may not) be significant that my file.encoding property is set to 'Cp1252' but when I override this using the java -D command option, I get the correct result.
So, in essense, my question is: why does Cp850 work but Cp1252 not work?
Thanks in advance for any help
Regards
JohnI could do, but that's not really a problem - I've already got the 'work around' I need using Cp850. I just want to understand WHY it does what it does, because it seems to me that Cp1252 should work as well.
-
TDMS Shell - DB Export from source/sender system taking a VERY long time
We're trying to build a TDMS Receiver system using the TDMS Shell technique. We've run into a situation wherein the initial DB Export from source/sender system is taking a VERY long time.
We are on ECC 6.0, running on AIX 6.1 and DB UDB v9.7. We're executing the DB export from sapinst, per instructions. Our DB export parallelizes, then the parallel processes one by one whittle away to just one remaining, and there we find out that the export is at that point single-threaded, and exporting table BSIS.
BSIS is an FI transactional data table. We're wondering why is the DB export trying to get BSIS and its contents out??? Isn't the DB export in TDMS Shell technique only supposed to get SAP essential only config and master data, and NOT transactional data?
Our BSIS table is nearly 700 GB in size by itself. That export has been running for nearly a week now, with no end in site.
What are we doing wrong? We suspect we may have missed something, but really don't think we do. We also suspect that the EXCLUSION table in the TDMS Shell technique may be the KEY to this whole thing. It's supposed to automatically exclude very large tables, but in this case, it most certainly missed out in excluding BSIS for some reason.
Anyway, we're probably going to fire up an OSS Message with SAP Support to help us address this perplexing issue. Just thought we'd throw it out there to the board to see if anyone else somewhere has run into similar circumstances and challenges. In the meantime, any feedback and/or advice would be dearly appreciated. Cheers,Hello
Dont be bothered by the other TPL file DDLDB6_LRG.TPL, we are only concerned with DDLDB6.TPl.
Answer following questions to help me analyze the situation -
1) What is the current size of export dump
2) Since when is the exports running
3) What is the size of the source DB? Do you have huge amount of custom developments?
4) Did you try to use table splitting?
5) Do you doubt that there may be other transaction tables (like BSIS) which have been exported completely?
6) Did you update the SAP Kernel of your source system to latest version before starting the Shell package?
7) Were the DB statistics update during the shell or were they already updated before starting Shell?
8) Is your system a distributed system i.e. Central instance and Database instance are on different application servers? -
Invoking Java from C and capturing System.out
Hi,
I know very little about C but have a question related to invoking a Java process from C. Perhaps someone can help me.
I've been looking at the example at http://java.sun.com/docs/books/jni/html/invoke.html and seen how to invoke my Java program with:
(*env)->CallStaticVoidMethod(env, cls, mid, args);
in their example the Java program prints one line to System out with:
System.out.println("Hello World " + args[0]);
and says running the program produces:
Hello World from C!
What I want to know is, how in the C program can I capture the output the Java program sends to System.out, as I want to do something with the output other than have it print into the console.
Hope that makes sense.I'm not totally clear on your question but I'll take a stab.
It seems to me like you are trying to get the output from a java program into a C program. If this is the case then there are many ways to do this - many of which are more simple that using JNI. However, if you absolutely must use JNI for this application then I suggest you take some more time to learn about C and JNI as I imagine this sort of thing is non-trivial and will required a level of understanding of C that you currently don't have. You may also want to cross-post onto the JNI forum.
If you can do this without using JNI then I'd suggest doing the standard fork/exec/pipe routine. This means, that in your C program you will call the functions fork (to create a new process that is subordinate to the currently running one), exec (in the subprocess which will replace the current program image in memory with that of another program you wish to execute, in this case, a JVM with a running application), and popen (which creates a "pipe" between the standard output of the Java program [System.out] and some input stream in the C program).
Finding an example of a program that does this fork/exec/pipe pattern on the web shouldn't be too hard. Hope this helps.
-mike -
JAXB Unmarshaller and errors to system.out
Hi!
I'm using JAXB in a complex XML binding project. The question is: is there a way to prevent javax.xml.bind.Unmarshaller to send to system.out the warnings/errors messages as DefaultValidationEventHandler: [ERROR]: bla bla bla
which are sent immediately before to throw an UnmarshalException??
Thanks so much!!Have you tried using System.setErr() and System.setOut() ? With these calls at the start of your application, you should be able to redirect the error to a file or whatever you want.
-
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>
Maybe you are looking for
-
This external hard disk used to serve as the main drive of my mbp. It got corrupted and the OSX would no longer load. I upgraded to a 500gb hd and used the old hd as an external drive. I tried to copy my files but i could not access them because of t
-
How do I get a transparent background behind a graphic?
I haven't worked in Indesign in two years, and forgot a lot, but I'm getting up to speed for a new job. While, I'm designing collateral, I need to get clip art and graphics placed in the document, but everything is coming in with the dreaded white b
-
Outlook express, What happened to my mail folders??
My file folders have dissapeared from outlook and are now in my documents with a dbx file that I cannot open. How do I restore the files to outlook express? thanks.
-
Change system time in SAP.
Dear Expertise, Our system time SAP is behind from system time in our Active Directory about 30 minutes. Can our SAP system time be accelerated so our SAP system time is same with system time in AD? what should we note? Our OS is HP-UX 11.31, SAP R/3
-
How to install operamini 5.1 in Nokia 2730 Classic
Respected all I have Nokia 2730 classic with operamini 4.1. I want to install or upgrade it from 4.1 to 5.1. I had downloaded operamini 5.1 but when i install this shows an error "Unable to connect to the internet.Please cheak your settings."Bu