Server Dout
Hi all,
I have some douts in Web application .
1. What is application server? What for we can use this ? Where we can use this ? Tell me 1 example.
2. What is web server? What for we can use this ? Where we can use this ? Tell me 1 example.
3. What is Httpservelt ? Tell me some example
4 .What is Genericservlet ? Tell me some example.
I am confused with this ...........Can any one help me ?
Suresh S
Hi all,
I have some douts in Web application .I have some doubts about your spelling.
1. What is application server? What for we can use
this ? Where we can use this ? Tell me 1 example.JBoss, BEA WebLogic, for example
2. What is web server? What for we can use this ?
Where we can use this ? Tell me 1 example.Apache, Internet Information Server, for example.
3. What is Httpservelt ? Tell me some exampleAs you wrote it? Nothing (Java is case sensitive). HttpServlet is an interface that descripes the contract that an HTTP servlet must implement.
4 .What is Genericservlet ? Tell me some example.As you wrote it? Nothing (Java is case sensitive). GenericServlet is an abstract implementation of HttpServlet which provides a common base class to write servlets from.
I am confused with this ...........Can any one help me ?Sounds like a loaded question to me.... :-)
You could have searched the web for this info a lot faster then you've waited for replies.
Similar Messages
-
How to make the client connect to the server at the command prompt?
I found this code on IBM's website, it was a training session on servers and clients using java.
The code compiles fine and the server seems to start up properly when I use java Server 5000. I think whats happening is the server is running and listening for a connection on port 5000.
When I try to run the client I get the following error.
Exception in thread "main" java.lang.NoSuchMethodError: main
I see a start() method but no main. As far as I know, applications should all have main, it seems as if the person who wrote this kinda confused applets with application. Not that I would really know what happened.
If you have time, could you tell me if there's an easy fix for this? I would love to have this client/server working if it isn't too much trouble. As I have looked all over the net for a free client/server applet that will actually let me see the java code and none of the free ones do allow getting to their source.
Most of them allow you to customize them somewhat but also have built in advertising that can't be removed.
This is the closest I have come to finding one that lets me look under the hood. But alas it doesn't work out of the box and I don't know what to do to fix it.
Heres the code: Server:
import java.io.*;
import java.net.*;
import java.util.*;
public class Server
// The ServerSocket we'll use for accepting new connections
private ServerSocket ss;
// A mapping from sockets to DataOutputStreams. This will
// help us avoid having to create a DataOutputStream each time
// we want to write to a stream.
private Hashtable outputStreams = new Hashtable();
// Constructor and while-accept loop all in one.
public Server( int port ) throws IOException {
// All we have to do is listen
listen( port );
private void listen( int port ) throws IOException {
// Create the ServerSocket
ss = new ServerSocket( port );
// Tell the world we're ready to go
System.out.println( "Listening on "+ss );
// Keep accepting connections forever
while (true) {
// Grab the next incoming connection
Socket s = ss.accept();
// Tell the world we've got it
System.out.println( "Connection from "+s );
// Create a DataOutputStream for writing data to the
// other side
DataOutputStream dout = new DataOutputStream( s.getOutputStream() );
// Save this stream so we don't need to make it again
outputStreams.put( s, dout );
// Create a new thread for this connection, and then forget
// about it
new ServerThread( this, s );
// Get an enumeration of all the OutputStreams, one for each client
// connected to us
Enumeration getOutputStreams() {
return outputStreams.elements();
// Send a message to all clients (utility routine)
void sendToAll( String message ) {
// We synchronize on this because another thread might be
// calling removeConnection() and this would screw us up
// as we tried to walk through the list
synchronized( outputStreams ) {
// For each client ...
for (Enumeration e = getOutputStreams(); e.hasMoreElements(); ) {
// ... get the output stream ...
DataOutputStream dout = (DataOutputStream)e.nextElement();
// ... and send the message
try {
dout.writeUTF( message );
} catch( IOException ie ) { System.out.println( ie ); }
// Remove a socket, and it's corresponding output stream, from our
// list. This is usually called by a connection thread that has
// discovered that the connectin to the client is dead.
void removeConnection( Socket s ) {
// Synchronize so we don't mess up sendToAll() while it walks
// down the list of all output streamsa
synchronized( outputStreams ) {
// Tell the world
System.out.println( "Removing connection to "+s );
// Remove it from our hashtable/list
outputStreams.remove( s );
// Make sure it's closed
try {
s.close();
} catch( IOException ie ) {
System.out.println( "Error closing "+s );
ie.printStackTrace();
// Main routine
// Usage: java Server <port>
static public void main( String args[] ) throws Exception {
// Get the port # from the command line
int port = Integer.parseInt( args[0] );
// Create a Server object, which will automatically begin
// accepting connections.
new Server( port );
}CLIENT:
import java.io.*;
import java.net.*;
public class ServerThread extends Thread
// The Server that spawned us
private Server server;
// The Socket connected to our client
private Socket socket;
// Constructor.
public ServerThread( Server server, Socket socket ) {
// Save the parameters
this.server = server;
this.socket = socket;
// Start up the thread
start();
// This runs in a separate thread when start() is called in the
// constructor.
public void run() {
try {
// Create a DataInputStream for communication; the client
// is using a DataOutputStream to write to us
DataInputStream din = new DataInputStream( socket.getInputStream() );
// Over and over, forever ...
while (true) {
// ... read the next message ...
String message = din.readUTF();
// ... tell the world ...
System.out.println( "Sending "+message );
// ... and have the server send it to all clients
server.sendToAll( message );
} catch( EOFException ie ) {
// This doesn't need an error message
} catch( IOException ie ) {
// This does; tell the world!
ie.printStackTrace();
} finally {
// The connection is closed for one reason or another,
// so have the server dealing with it
server.removeConnection( socket );
}Thanks for your time.CLIENT:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
public class Client extends Panel implements Runnable
// Components for the visual display of the chat windows
private TextField tf = new TextField();
private TextArea ta = new TextArea();
// The socket connecting us to the server
private Socket socket;
// The streams we communicate to the server; these come
// from the socket
private DataOutputStream dout;
private DataInputStream din;
// Constructor
public Client( String host, int port ) {
// Set up the screen
setLayout( new BorderLayout() );
add( "North", tf );
add( "Center", ta );
// We want to receive messages when someone types a line
// and hits return, using an anonymous class as
// a callback
tf.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
processMessage( e.getActionCommand() );
// Connect to the server
try {
// Initiate the connection
socket = new Socket( host, port );
// We got a connection! Tell the world
System.out.println( "connected to "+socket );
// Let's grab the streams and create DataInput/Output streams
// from them
din = new DataInputStream( socket.getInputStream() );
dout = new DataOutputStream( socket.getOutputStream() );
// Start a background thread for receiving messages
new Thread( this ).start();
} catch( IOException ie ) { System.out.println( ie ); }
// Gets called when the user types something
private void processMessage( String message ) {
try {
// Send it to the server
dout.writeUTF( message );
// Clear out text input field
tf.setText( "" );
} catch( IOException ie ) { System.out.println( ie ); }
// Background thread runs this: show messages from other window
public void run() {
try {
// Receive messages one-by-one, forever
while (true) {
// Get the next message
String message = din.readUTF();
// Print it to our text window
ta.append( message+"\n" );
} catch( IOException ie ) { System.out.println( ie ); }
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
public class ClientApplet extends Applet
public void init() {
String host = getParameter( "192.168.1.47" );
int port = Integer.parseInt( getParameter( "5000" ) );
setLayout( new BorderLayout() );
add( "Center", new Client( host, port ) );
}Sorry about that. Now when I run an html file with this applet I just get the x in the corner.
Thanks for looking. -
Trying to produce a java chat server
Would like produce a working client/server chat system, as basic as possible but able to listen and talk to each other. Any chat servers how-to examples I've come across never seem to work.
Would like to understand why applets don't work when I open the web page but do work when I view using the appletviewer. I use Internet Explorer 4 i think, java version 1.3.0_02
would you understand at least part of this error which appears when I run a chat server
exception:com.ms.security.SecurityExceptionEx[Client.<int>]:cannot access "194.81.104.26":5660
(the error is all one line no spaces)
the following code is one of the programs I've been working on and I receive the above error, appletviewer doesn't work so i think that means something is wrong with the code, client side as the server side works well, it listens etc
// Client side
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
public class Client extends Panel implements Runnable
// Components for the visual display of the chat windows
private TextField tf = new TextField();
private TextArea ta = new TextArea();
// The socket connecting us to the server
private Socket socket;
// The streams we communicate to the server; these come
// from the socket
private DataOutputStream dout;
private DataInputStream din;
// Constructor
public Client( String host,int port ) {
// Set up the screen
setLayout( new BorderLayout() );
add( "North", tf );
add( "Center", ta );
// Receive messages when someone types a line
// and hits return, using an anonymous class as
// a callback
tf.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
processMessage( e.getActionCommand() );
// Connect to the server
try {
// Initiate the connection
socket = new Socket( host, port );
// Recieved a connection
System.out.println( "connected to "+socket );
// Create DataInput/Output streams
din = new DataInputStream( socket.getInputStream() );
dout = new DataOutputStream( socket.getOutputStream() );
// Start a background thread for receiving messages
new Thread( this ).start();
} catch( IOException ie ) { System.out.println( ie ); }
// Called when the user types something
private void processMessage( String message ) {
try {
// Send it to the server
dout.writeUTF( message );
// Clear out text input field
tf.setText( "" );
} catch( IOException ie ) { System.out.println( ie ); }
// Background thread runs this: show messages from other window
public void run() {
try {
// Receive messages one-by-one, forever
while (true) {
// Get the next message
String message = din.readUTF();
// Print it to our text window
ta.append( message+"\n" );
} catch( IOException ie ) { System.out.println( ie ); }
// ClientApplet
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
public class ClientApplet extends Applet
public void init() {
//String host = getParameter( "host" );
String host="194.81.104.26";
//int port = Integer.parseInt( getParameter( "port" ) );
int port =5660;
setLayout( new BorderLayout() );
add( "Center", new Client( host, port ) );
// server
import java.io.*;
import java.net.*;
import java.util.*;
public class Server
// The ServerSocket is used for accepting new connections
private ServerSocket ss;
// A mapping from sockets to DataOutputStreams. This will
// help us avoid having to create a DataOutputStream each time
// we want to write to a stream.
private Hashtable outputStreams = new Hashtable();
// Constructor and while-accept loop all in one.
public Server( int port ) throws IOException {
// listening
listen( port );
private void listen( int port ) throws IOException {
// Create the ServerSocket
ss = new ServerSocket( port);
// ServerSocket is listening
System.out.println( "Listening on "+ss );
// Keep accepting connections forever
while (true) {
// The next incoming connection
Socket s = ss.accept();
// Connection
System.out.println( "Connection from "+s );
// Create a DataOutputStream for writing data to the
// other side
DataOutputStream dout = new DataOutputStream( s.getOutputStream() );
// Save this stream so we don't need to make it again
outputStreams.put( s, dout );
// Create a new thread for this connection, and then forget
// about it
new ServerThread( this, s );
// Get an enumeration of all the OutputStreams, one for each client
// connected to us
Enumeration getOutputStreams() {
return outputStreams.elements();
// Send a message to all clients (utility routine)
void sendToAll( String message ) {
// We synchronise on this because another thread might be
// calling removeConnection()
synchronized( outputStreams ) {
// For each client ...
for (Enumeration e = getOutputStreams(); e.hasMoreElements(); ) {
// ... get the output stream ...
DataOutputStream dout = (DataOutputStream)e.nextElement();
// ... and send the message
try {
dout.writeUTF( message );
} catch( IOException ie ) { System.out.println( ie ); }
// Remove a socket, and it's corresponding output stream, from our
// list. This is usually called by a connection thread that has
// discovered that the connectin to the client is dead.
void removeConnection( Socket s ) {
// Synchronise so sendToAll() is okay while it walks
// down the list of all output streams
synchronized( outputStreams ) {
// Removing connection
System.out.println( "Removing connection to "+s );
// Remove it from our hashtable/list
outputStreams.remove( s );
// Make sure it's closed
try {
s.close();
} catch( IOException ie ) {
System.out.println( "Error closing "+s );
ie.printStackTrace();
// Main routine
// Usage: java Server <port>
static public void main( String args[] ) throws Exception {
// Get the port # from the command line
int port = Integer.parseInt( args[0] );
//int port = 5000;
// Create a Server object, which will automatically begin
// accepting connections.
new Server( port);
// ServerThread
import java.io.*;
import java.net.*;
public class ServerThread extends Thread
// The Server that spawned
private Server server;
// The Socket connected to our client
private Socket socket;
// Constructor.
public ServerThread( Server server, Socket socket ) {
// Save the parameters
this.server = server;
this.socket = socket;
// Start up the thread
start();
// This runs in a separate thread when start() is called in the
// constructor.
public void run() {
try {
// Create a DataInputStream for communication; the client
// is using a DataOutputStream to write to us
DataInputStream din = new DataInputStream( socket.getInputStream() );
// Over and over, forever ...
while (true) {
// ... read the next message ...
String message = din.readUTF();
// ... sending printed to screen ...
System.out.println( "Sending "+message );
// ... and have the server send it to all clients
server.sendToAll( message );
} catch( EOFException ie ) {
// This doesn't need an error message
} catch( IOException ie ) {
// This needs an error message
ie.printStackTrace();
} finally {
// The connection is closed for one reason or another,
// so have the server dealing with it
server.removeConnection( socket );
<body bgcolor="#FFFFFF">
<applet code="ClientApplet" width=600 height=400>
<param name=host value="127.0.0.1">
<param name=port value="5660">
[Chat applet]
</applet>
</body>Hi!
Go to
http://www.freecode.com/projects/jchat-java2clientserverchatmodule/
probably u will het the answer..
Jove -
Non-Blocking I/O Implementation Issue
Hi All,
I am trying out the latest JDK 1.4 java.nio.* package. I modified the NBTimeServer and wrote a client which connects to the NBTimeServer and tries to pass messages to and fro. I always succeed to pass on roundtrip of msgs and then Server blocks my client forever. I have modified NBTimeServer to accomodate one client only. Any help or comments on this would be really appreciated. Code is below. Feel free to try it out if want to see what I am trying to convey in this message.
/*******Server Code*******/
Modified this code to test mulitple to and fro msgs between client and server.
Only one client will ever be able to connect to this server during life of a server.
My point here is to demonstrate the to and fro comm between one client and one server
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.net.*;
import java.util.*;
import java.nio.charset.*;
import java.util.regex.*;
// Listen on a port for connections and write back the current time.
public class NBTimeServer {
private static final int DEFAULT_TIME_PORT = 8900;
// Constructor with no arguments creates a time server on default port.
public NBTimeServer() throws Exception {
acceptConnections(this.DEFAULT_TIME_PORT);
// Constructor with port argument creates a time server on specified port.
public NBTimeServer(int port) throws Exception {
acceptConnections(port);
// Accept connections for current time. Lazy Exception thrown.
private static void acceptConnections(int port) throws Exception {
// Selector for incoming time requests
Selector acceptSelector = SelectorProvider.provider().openSelector();
Selector rwSelector = SelectorProvider.provider().openSelector();
// Create a new server socket and set to non blocking mode
ServerSocketChannel ssc = ServerSocketChannel.open();
ssc.configureBlocking(false);
// Bind the server socket to the local host and port
InetAddress lh = InetAddress.getLocalHost();
InetSocketAddress isa = new InetSocketAddress(lh, port);
ssc.socket().bind(isa);
// Register accepts on the server socket with the selector. This
// step tells the selector that the socket wants to be put on the
// ready list when accept operations occur, so allowing multiplexed
// non-blocking I/O to take place.
SelectionKey acceptKey = ssc.register(acceptSelector,
SelectionKey.OP_ACCEPT);
int keysAdded = 0;
// Here's where everything happens. The select method will
// return when any operations registered above have occurred, the
// thread has been interrupted, etc.
while ((keysAdded = acceptSelector.select()) > 0) {
// Someone is ready for I/O, get the ready keys
Set readyKeys = acceptSelector.selectedKeys();
Iterator i = readyKeys.iterator();
// Walk through the ready keys collection and process date requests.
while (i.hasNext()) {
SelectionKey sk = (SelectionKey)i.next();
i.remove();
// The key indexes into the selector so you
// can retrieve the socket that's ready for I/O
ServerSocketChannel nextReady =
(ServerSocketChannel)sk.channel();
// Accept the date request and send back the date string
Socket s = nextReady.accept();
SocketChannel sc = s.getChannel();
System.out.println("Got client channel..");
sc.configureBlocking(false);
SelectionKey readKey = sc.register(rwSelector,
SelectionKey.OP_READ|SelectionKey.OP_WRITE);
int count = 0;
while(true) {
if((count = rwSelector.select(1000L)) > 0) {
Set readKeys = rwSelector.selectedKeys();
Iterator i1 = readKeys.iterator();
while(i1.hasNext()) {
System.out.println("Loop in Iterator");
SelectionKey sk1 = (SelectionKey)i1.next();
i1.remove();
if(sk1.isReadable()) {
DataInputStream sin = new DataInputStream(new BufferedInputStream(s.getInputStream(), 4096));
System.out.println(sin.readInt());
if(sk1.isWritable()) {
DataOutputStream sout = new DataOutputStream(new BufferedOutputStream(s.getOutputStream(), 4096));
PrintWriter out = new PrintWriter(sout, true);
Date now = new Date();
out.println(now);
// Entry point.
public static void main(String[] args) {
// Parse command line arguments and
// create a new time server (no arguments yet)
try {
NBTimeServer nbt = new NBTimeServer();
} catch(Exception e) {
e.printStackTrace();
/******End Server Code********/
/*****Begin Client Code********/
import java.io.*;
import java.net.*;
import java.util.*;
// Listen on a port for connections and write back the current time.
public class NBTimeClient {
private static final int DEFAULT_TIME_PORT = 8900;
public static void main(String args[]) throws Exception {
InetAddress lh = InetAddress.getLocalHost();
Socket s = new Socket(lh, DEFAULT_TIME_PORT);
DataInputStream din = new DataInputStream(new BufferedInputStream(s.getInputStream(), 4096));
DataOutputStream dout = new DataOutputStream(new BufferedOutputStream(s.getOutputStream(), 4096));
//Read the time
System.out.println(din.readLine());
//send some junk which is read by server
dout.writeInt(1299);
dout.flush();
//read time again -- I never get anything here and I am blocked here...
System.out.println(din.readLine());
//send some junk back to the server
dout.writeInt(1299);
dout.flush();
s.close();
/*******End Client Code**********/
thanks,
XtrimityThe reason it blocks forever is that you need to keep reusing your main select. That is where the non-blocking event will come from. Here is a bit of code that doesn't block forever.
Tim
http://tim.owlmountain.com
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import java.nio.channels.spi.*;
import java.net.*;
import java.util.*;
import org.apache.log4j.*;
public class NBServer3 {
int _port = 4000;
Selector _selector = null;
ServerSocketChannel _selectableChannel = null;
int _keysAdded = 0;
static Category log =
Category.getInstance(NBServer3.class.getName());
static String QUIT_SERVER = "quit";
public NBServer3() {
public NBServer3( int port ) {
this._port = port;
public void initialize()
throws IOException {
this._selector = SelectorProvider.provider().openSelector();
this._selectableChannel = ServerSocketChannel.open();
this._selectableChannel.configureBlocking(false);
InetAddress lh = InetAddress.getLocalHost();
InetSocketAddress isa = new InetSocketAddress(lh, this._port );
this._selectableChannel.socket().bind(isa);
public void finalize()
throws IOException {
this._selectableChannel.close();
this._selector.close();
public void acceptConnections()
throws IOException {
Selects a set of keys whose corresponding channels are ready for I/O
operations. This method performs a non-blocking selection operation.
If no channels have become selectable since the previous selection
operation then this method immediately returns zero.
Returns:
The number of keys, possibly zero, whose ready-operation sets
were updated by the selection operation
do {
SelectionKey acceptKey =
this._selectableChannel.register( this._selector,
SelectionKey.OP_ACCEPT );
log.debug( "Acceptor loop..." );
while (( this._keysAdded = acceptKey.selector().select()) > 0 ) {
log.debug( "Selector returned "
+ this._keysAdded + " ready for IO operations" );
Set readyKeys = this._selector.selectedKeys();
Iterator i = readyKeys.iterator();
while (i.hasNext()) {
SelectionKey key = (SelectionKey)i.next();
i.remove();
if ( key.isAcceptable() ) {
ServerSocketChannel nextReady =
(ServerSocketChannel)key.channel();
log.debug( "Processing selection key read="
+ key.isReadable() + " write=" + key.isWritable() +
" accept=" + key.isAcceptable() );
Socket s = nextReady.accept();
s.getChannel().configureBlocking( false );
SelectionKey readKey =
s.getChannel().register( this._selector,
SelectionKey.OP_READ );
readKey.attach( s );
else if ( key.isReadable() ) {
SelectableChannel nextReady =
(SelectableChannel) key.channel();
log.debug( "Processing selection key read="
+ key.isReadable() + " write=" + key.isWritable() +
" accept=" + key.isAcceptable() );
Socket socket = (Socket) key.attachment();
BufferedReader in = new BufferedReader(
new InputStreamReader( socket.getInputStream() ));
String line = null;
if ( (line = in.readLine() ) != null )
log.debug( line );
log.debug( "End acceptor loop..." );
} while ( false ); //FIXIT tim this should be false. justa test
public static void main( String[] args ) {
BasicConfigurator.configure();
NBServer3 nbServer = new NBServer3();
try {
nbServer.initialize();
} catch ( IOException e ) {
e.printStackTrace();
System.exit( -1 );
try {
nbServer.acceptConnections();
catch ( IOException e ) {
e.printStackTrace();
log.error( e ); -
i doing a chat application and using vector for storing the usernames...but when i use the contains method in vector my client applet will hang...could anyone give me any example of chat server validating username and sending result back to client code....
below are my source code....pls help
ChatServer.java
import java.net.*;
import java.io.*;
import java.util.*;
public class ChatServer {
static LinkedList ClientList = new LinkedList();
public static void main (String args[]) throws IOException {
ServerSocket server = new ServerSocket (10000);
while (true) {
System.out.println( "Waiting for connection...");
Socket client = server.accept ();
ClientList.add( client );
System.out.println ("Accepted from " + client.getInetAddress ());
ChatHandler c = new ChatHandler (client);
c.start ();
ChatHandler.java
import java.net.*;
import java.io.*;
import java.util.*;
import javax.swing.JOptionPane;
public class ChatHandler extends Thread {
protected Socket s;
protected DataInputStream i;
protected DataOutputStream o;
String name;
public ChatHandler (Socket s) throws IOException {
this.s = s;
i = new DataInputStream (new BufferedInputStream (s.getInputStream ()));
o = new DataOutputStream (new BufferedOutputStream (s.getOutputStream ()));
protected static Vector clientlist = new Vector ();
protected static Vector handlers = new Vector ();
public void run () {
try {
name = i.readUTF();
if( name.startsWith( "NICKNAME:" ) )
name = name.substring( 9 );
if ( clientlist.contains( name ) )
o.writeUTF( "false" );
else
broadcast (name + " has joined.");
handlers.addElement (this);
clientlist.addElement(name);
Enumeration enum = clientlist.elements();
while ( enum.hasMoreElements() )
broadcast ( "USERLIST:" + (String)enum.nextElement() );
while (true) {
String msg = i.readUTF ();
if(msg.equals("/who"))
Enumeration enum = clientlist.elements();
while ( enum.hasMoreElements() )
broadcast ( "USERLIST:" + (String)enum.nextElement() );
broadcast (name + " - " + msg);
} catch (IOException ex) {
ex.printStackTrace ();
} finally {
handlers.removeElement (this);
broadcast (name + " has left.");
try {
s.close ();
} catch (IOException ex) {
ex.printStackTrace();
protected static void broadcast (String message) {
synchronized (handlers) {
Enumeration e = handlers.elements ();
while (e.hasMoreElements ()) {
ChatHandler c = (ChatHandler) e.nextElement ();
try {
synchronized (c.o) {
c.o.writeUTF (message);
c.o.flush ();
} catch (IOException ex) {
c.stop ();
ChatClient.java
// The chat applet gui
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.JOptionPane;
import java.io.*;
import java.net.*;
import java.util.*;
public class ChatClient extends JApplet implements ActionListener, Runnable {
Container c;
JPanel mainPanel, chatLoginPanel, chatPanel, chatPanel_bottom;
JTextField nickNameText, chatText;
JTextArea chatArea;
JList userList;
JButton enterChatButton, exitChatButton;
JLabel nickLabel;
// socket for connecting to the server
private Socket socket;
private DataOutputStream dout;
private DataInputStream din;
public void init()
c = getContentPane();
// The JPanel with CardLayout
mainPanel = new JPanel();
mainPanel.setLayout( new CardLayout() );
// chatLoginPanel for user login into chat
chatLoginPanel = new JPanel();
chatLoginPanel.setLayout( new FlowLayout() );
nickLabel = new JLabel( "Nickname:" );
nickNameText = new JTextField( 20 );
enterChatButton = new JButton( "Enter" );
enterChatButton.addActionListener( this );
enterChatButton.setActionCommand( "Enter Chat" );
chatLoginPanel.add( nickLabel );
chatLoginPanel.add( nickNameText );
chatLoginPanel.add( enterChatButton );
chatLoginPanel.setBackground( Color.white );
// chatPanel for user chatting
chatPanel = new JPanel();
chatPanel.setLayout( new BorderLayout() );
chatArea = new JTextArea( 9, 31 );
userList = new JList();
userList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
userList.setVisibleRowCount( 0 );
userList.setFixedCellWidth( 90 );
chatPanel_bottom = new JPanel();
chatPanel_bottom.setLayout( new BorderLayout() );
chatText = new JTextField( 31 );
chatText.addActionListener( this );
chatText.setActionCommand( "Chat Text" );
exitChatButton = new JButton( "Exit from chat" );
exitChatButton.addActionListener( this );
exitChatButton.setActionCommand( "Exit Chat" );
chatPanel_bottom.add( BorderLayout.WEST, chatText );
chatPanel_bottom.add( BorderLayout.EAST, exitChatButton );
chatPanel.add( BorderLayout.WEST, new JScrollPane( chatArea ) );
chatPanel.add( BorderLayout.EAST, new JScrollPane( userList ) );
chatPanel.add( BorderLayout.SOUTH, chatPanel_bottom );
chatPanel_bottom.setBackground( Color.white );
chatPanel.setBackground( Color.white );
c.add( chatLoginPanel );
// Connecting to the server
try {
// Initiate the connection
socket = new Socket( "127.0.0.1", 10000 );
// We got a connection! Tell the world
System.out.println( "connected to "+socket );
// Let's grab the stream and create DataInput/Output stream
// from them
din = new DataInputStream( socket.getInputStream() );
dout = new DataOutputStream( socket.getOutputStream() );
// Start a background thread for receiving messages
new Thread( this ).start();
} catch( IOException ie ) { System.out.println( ie ); }
private void processMessage( String message ) {
try {
// Send it to the server
dout.writeUTF( message );
// Clear out text input field
chatText.setText( "" );
} catch( IOException ie ) { System.out.println( ie ); }
// Background thread runs this, show messages from other window
public void run() {
try {
// Receive messages one-by-one, forever
while (true) {
// Get the next message
String message = din.readUTF();
if( message.equals( "false" ) )
JOptionPane.showMessageDialog( null, "The nickname you entered is already choosed", "Cannot enter", JOptionPane.PLAIN_MESSAGE );
nickNameText.setEditable( true );
enterChatButton.setText( "Enter" );
enterChatButton.setEnabled( true );
else if ( message != null )
//userList.setListData( chatPro.userListed() );
mainPanel.add( chatLoginPanel, "chatLoginPanel" );
mainPanel.add( chatPanel, "chatPanel" );
CardLayout cl = ( CardLayout )( mainPanel.getLayout() );
cl.show( mainPanel, ( String )"chatPanel" );
c.add( mainPanel );
// Print it to our text window
chatArea.append( message+"\n" );
} catch( IOException ie ) { System.out.println( ie ); }
public void actionPerformed( ActionEvent e )
if ( e.getActionCommand() == "Enter Chat")
nickNameText.setEditable( false );
enterChatButton.setText( "Validating" );
enterChatButton.setEnabled( false );
if( nickNameText.getText().equals("") )
JOptionPane.showMessageDialog( null, "Please key in your nickname", "Cannot enter", JOptionPane.PLAIN_MESSAGE );
nickNameText.setEditable( true );
enterChatButton.setText( "Enter" );
enterChatButton.setEnabled( true );
else
String userName = nickNameText.getText();
processMessage( "NICKNAME:" + userName );
if ( e.getActionCommand() == "Exit Chat")
mainPanel.add( chatLoginPanel, "chatLoginPanel" );
mainPanel.add( chatPanel, "chatPanel" );
CardLayout cl = ( CardLayout )( mainPanel.getLayout() );
cl.show( mainPanel, ( String )"chatLoginPanel" );
c.add( mainPanel );
nickNameText.setEditable( true );
enterChatButton.setText( "Enter" );
enterChatButton.setEnabled( true );
if ( e.getActionCommand() == "Chat Text" )
processMessage( chatText.getText() ); -
How to implement logger in this ftp server
I have written a FTP Server that is used by the clients to upload xml over to the server.
Currently it is using a console and it is printing stuff out on a console.
I have tried a lot to implement a logger class so that all console messages get written to a file.
But it has not been working out at all.
I would deeply appreciate if all you java gurus out there could modify the code given below to correctly log messages to a log file.
Please do Explain if possible ...I will try to rectify this issue in several other applications i developed as well.
import java.net.*;
import java.io.*;
import java.util.*;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.text.Format;
import java.lang.Object;
import java.lang.*;
import javax.crypto.*;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.KeySpec;
public class FTPServer
{ public static void main(String args[]) throws Exception
{ ServerSocket soc=new ServerSocket(5217);
System.out.println("FTP Server Started on Port Number 5217");
while(true)
System.out.println("Waiting for Connection ...");
transferfile t=new transferfile(soc.accept());
class transferfile extends Thread
Socket ClientSoc;
DataInputStream din;
DataOutputStream dout;
transferfile(Socket soc)
{ try
{ ClientSoc=soc;
din=new DataInputStream(ClientSoc.getInputStream());
dout=new DataOutputStream(ClientSoc.getOutputStream());
System.out.println("FTP Client Connected ...");
System.out.println("External IP of Client ..." + ClientSoc.getInetAddress());
//System.out.println("FTP Client Connected ..." + ClientSoc.getRemoteSocketAddress());
start();
catch(Exception ex)
//encrypto routine starts
class DesEncrypter {
Cipher ecipher;
Cipher dcipher;
// 8-byte Salt
byte[] salt = {
(byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
(byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03 };
// Iteration count
int iterationCount = 19;
DesEncrypter(String passPhrase) {
try {
// Create the key
KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
SecretKey key = SecretKeyFactory.getInstance(
"PBEWithMD5AndDES").generateSecret(keySpec);
ecipher = Cipher.getInstance(key.getAlgorithm());
dcipher = Cipher.getInstance(key.getAlgorithm());
// Prepare the parameter to the ciphers
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
// Create the ciphers
ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
} catch (java.security.InvalidAlgorithmParameterException e) {
} catch (java.security.spec.InvalidKeySpecException e) {
} catch (javax.crypto.NoSuchPaddingException e) {
} catch (java.security.NoSuchAlgorithmException e) {
} catch (java.security.InvalidKeyException e) {
// Buffer used to transport the bytes from one stream to another
byte[] buf = new byte[1024];
public void encrypt(InputStream in, OutputStream out) {
try {
// Bytes written to out will be encrypted
out = new CipherOutputStream(out, ecipher);
// Read in the cleartext bytes and write to out to encrypt
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {
out.write(buf, 0, numRead);
out.close();
} catch (java.io.IOException e) {
public void decrypt(InputStream in, OutputStream out) {
try {
// Bytes read from in will be decrypted
in = new CipherInputStream(in, dcipher);
// Read in the decrypted bytes and write the cleartext to out
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {
out.write(buf, 0, numRead);
//added later on
in.close();
out.close();
} catch (java.io.IOException e) {
} //encryptor routine ends
//not implemented right now as we arent using the ftp server to download stuff...can be activated later on if we want
void SendFile() throws Exception
String filename=din.readUTF();
File f=new File(filename);
if(!f.exists())
dout.writeUTF("File Not Found");
return;
else
{ dout.writeUTF("READY");
FileInputStream fin=new FileInputStream(f);
int ch;
do
ch=fin.read();
dout.writeUTF(String.valueOf(ch));
while(ch!=-1);
fin.close();
dout.writeUTF("File Received Successfully");
String Compare(String filename) throws Exception
///dout.writeUTF("entering compare");
String dateTempString=new String();
Date dateValue=new Date();
SimpleDateFormat formatter = new SimpleDateFormat ("hhmmss");
dateTempString = formatter.format(dateValue);
File dir1 = new File("C:\\FTPnew");
boolean success2 = dir1.mkdir();
if (!success2) {
// Directory creation failed /Already Exists
File dir = new File("C:\\FTPnew\\server");
boolean success = dir.mkdir();
if (!success) {
// Directory creation failed /Already Exists
File ftemp=new File(dir,dateTempString + filename);
File fnewtemp=new File(dir,"new-enc-"+filename);
// Create encrypter/decrypter class
DesEncrypter encrypter = new DesEncrypter("My Pass Phrase!");
FileOutputStream fout=new FileOutputStream(fnewtemp);
int ch;
String temp;
do
{ temp=din.readUTF();
ch=Integer.parseInt(temp);
if(ch!=-1)
fout.write(ch);
}while(ch!=-1);
fout.close();
//dout.writeUTF("written temp en file");
// Decrypt
encrypter.decrypt(new FileInputStream(fnewtemp),
new FileOutputStream(ftemp));
//String Option;
dout.writeUTF("Delete");
System.out.println("File Upload Successfull--Duplicate file with timestamp Created");
boolean success1 = fnewtemp.delete();
return "hello" ;
void ReceiveFile() throws Exception
String ip=din.readUTF();
System.out.println("\tRequest Coming from Internal IP Address : "+ ip);
String filename=din.readUTF();
if(filename.compareTo("File not found")==0)
return;
// Destination directory
File dir11 = new File("C:\\FTPnew");
boolean success22 = dir11.mkdir();
if (!success22) {
// Directory creation failed /Already Exists
File dir = new File("C:\\FTPnew\\server");
boolean success21 = dir.mkdir();
if (!success21) {
// Directory creation failed /Already Exists
File f=new File(dir ,"enc-"+filename);
File fe=new File(dir,filename);
String option;
if(fe.exists())
//dout.writeUTF("File Already Exists");
String compvalue = Compare(filename);
//dout.writeUTF(compvalue);
if(compvalue.compareTo("hello")==0)
//dout.writeUTF("Transfer Completed");
return;
option=din.readUTF();
else
//dout.writeUTF("SendFile");
option="Y";
if(option.compareTo("Y")==0)
// Generate a temporary key.
// Create encrypter/decrypter class
DesEncrypter encrypter = new DesEncrypter("My Pass Phrase!");
FileOutputStream fout=new FileOutputStream(f);
int ch;
String temp;
do
{ temp=din.readUTF();
ch=Integer.parseInt(temp);
if(ch!=-1)
fout.write(ch);
}while(ch!=-1);
fout.close();
// Decrypt
encrypter.decrypt(new FileInputStream(f),
new FileOutputStream(fe));
boolean success2 = f.delete();
dout.writeUTF("Delete");
System.out.println("File Upload Successfull");
else
return;
public void run()
while(true)
try
String Command=din.readUTF();
if(Command.compareTo("SEND")==0)
System.out.println("\tSEND Command Received ...");
ReceiveFile();
continue;
catch(Exception ex)
//System.out.println("\tClient Terminated Abnormally ...........");
continue;
}Stick a
Logger log = Logger.getLogger( "me ftp server" );at the top.
Checn Sys.out.println to log.info( ... )
Add a logging prefs file.
http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/overview.html -
Issue with Ftp Client / Server using Sockets
I have developed a Ftp Client and a Ftp Server. The client Connects to the Ftp Server and sends files to the ftp server. It is a multi threaded server and can have multiple clients connecting to it.
If a client goes down...the server waits till the client comes up
Similarly the client waits if a server goes down and reconnects when the server is again up and running
i am having a strange issue here. When two clients go down and reconnect to the server...They take a long time to connect and transferring of files takes a long time...
Other wise in all other scenarios the duo work properly.
Any feedback and suggestion about this strange issue from all you java gurus out there will be deeply appreciated.
Here is the client code
import java.net.*;
import java.net.Socket;
import java.net.InetAddress;
import java.io.*;
import java.io.File;
import java.util.*;
import java.lang.*;
import java.lang.Object;
import javax.crypto.*;
import java.util.regex.*;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.KeySpec;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.File.*;
import java.nio.channels.FileLock;
public class FTPClient {
public static void main(String[] args) throws Exception
Timer timer = new Timer("Test Timer");
timer.scheduleAtFixedRate(new TimerTask()
private int counter = 0;
public void run() {
try {
System.out.println(counter++);
Socket soc=new Socket("xxx.x.x.xx",5217);
System.out.println("Socket Initialised.");
transferfileClient t=new transferfileClient(soc);
t.SendFile();
System.out.println("run complete.");
catch(Exception ex)
}, 10000, 40000);
static class transferfileClient
Socket ClientSoc;
DataInputStream din;
DataOutputStream dout;
BufferedReader br;
transferfileClient(Socket soc)
try
ClientSoc=soc;
din=new DataInputStream(ClientSoc.getInputStream());
dout=new DataOutputStream(ClientSoc.getOutputStream());
br=new BufferedReader(new InputStreamReader(System.in));
catch(Exception ex)
//encrypto routine starts
class DesEncrypter {
Cipher ecipher;
Cipher dcipher;
// 8-byte Salt
byte[] salt = {
(byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
(byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03
// Iteration count
int iterationCount = 19;
DesEncrypter(String passPhrase) {
try {
// Create the key
KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
SecretKey key = SecretKeyFactory.getInstance(
"PBEWithMD5AndDES").generateSecret(keySpec);
ecipher = Cipher.getInstance(key.getAlgorithm());
dcipher = Cipher.getInstance(key.getAlgorithm());
// Prepare the parameter to the ciphers
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
// Create the ciphers
ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
} catch (java.security.InvalidAlgorithmParameterException e) {
} catch (java.security.spec.InvalidKeySpecException e) {
} catch (javax.crypto.NoSuchPaddingException e) {
} catch (java.security.NoSuchAlgorithmException e) {
} catch (java.security.InvalidKeyException e) {
// Buffer used to transport the bytes from one stream to another
byte[] buf = new byte[1024];
public void encrypt(InputStream in, OutputStream out) {
try {
// Bytes written to out will be encrypted
out = new CipherOutputStream(out, ecipher);
// Read in the cleartext bytes and write to out to encrypt
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {
out.write(buf, 0, numRead);
out.close();
} catch (java.io.IOException e) {
public void decrypt(InputStream in, OutputStream out) {
try {
// Bytes read from in will be decrypted
in = new CipherInputStream(in, dcipher);
// Read in the decrypted bytes and write the cleartext to out
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {
out.write(buf, 0, numRead);
out.close();
} catch (java.io.IOException e) {
} //encryptor routine ends
void SendFile() throws Exception
try
String directoryName;
// File object referring to the directory.
String[] files; // Array of file names in the directory.
//directory = new File ( "C:\\FTP\\" ) ;
File directory1 = new File("C:\\FTP");
boolean successmk = directory1.mkdir();
if (!successmk) {
// Directory creation failed /Already Exists
File directory = new File("C:\\FTP\\ftpc");
boolean successmk1 = directory.mkdir();
if (!successmk1) {
// Directory creation failed /Already Exists
//directory = new File ( "E:\\FTP-encrypted" ) ;
if (directory.isDirectory() == false) {
if (directory.exists() == false)
System.out.println("There is no such directory!");
else
System.out.println("That file is not a directory.");
else {
files = directory.list();
System.out.println("Files in directory \"" + directory + "\":");
for (int i = 0; i < files.length; i++)
String patternStr = "xml";
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(files);
boolean matchFound = matcher.find();
if (matchFound) {
System.out.println(" " + files[i]);
String filename;
filename=files[i];
File f=new File(directory,filename);
FileLock lock = null;
FileOutputStream fos = new FileOutputStream(f, true);
lock = fos.getChannel().tryLock();
if (lock == null) {
System.out.println(" Failed to get the file lock: means that the file is locked by other instance.");
fos.close();
else
InetAddress addr = InetAddress.getLocalHost();
// Get IP Address
//byte[] ipAddr = addr.getAddress();
String ip= addr.toString();
// Get hostname
//String hostname = addr.getHostName();
System.out.println(" Lock Acquired.");
lock.release();
fos.close();
dout.writeUTF("SEND");
dout.writeUTF(ip);
dout.writeUTF(filename);
//String msgFromServer=din.readUTF();
DesEncrypter encrypter = new DesEncrypter("My Pass Phrase!");
// Encrypt
FileInputStream fino=new FileInputStream(f);
encrypter.encrypt(fino,
new FileOutputStream("ciphertext.txt"));
fino.close();
FileInputStream fin=new FileInputStream("ciphertext.txt");
int ch;
do
ch=fin.read();
dout.writeUTF(String.valueOf(ch));
while(ch!=-1);
fin.close();
String option;
option=din.readUTF();
if((option.compareTo("Delete")==0))
boolean success = (new File("ciphertext.txt")).delete();
boolean success1 = f.delete();
if (success) {
System.out.println("File Sent ...");
if (success1) {
System.out.println("--File deleted from Client ...");
for (int j = 0; j < 999999999; j++){}
}//pattermatch loop ends here
else
{ //System.out.println(" " + "Not an XML file-------->" +files[i]);
for (int jb = 0; jb < 111999999; jb++){}
}// for loop ends here for files in directory
}//else loop ends for directory files listing
System.out.println("sendfile finished...");
return;
} catch(Exception ex) {ex.printStackTrace();}
}//sendfile ends here
public void displayMenu() throws Exception
System.out.println(" Send File");
SendFile();
return;
And here is the server code...
import java.net.*;
import java.io.*;
import java.util.*;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
import java.text.Format;
import java.lang.Object;
import java.lang.*;
import javax.crypto.*;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.KeySpec;
public class FTPServer
{ public static void main(String args[]) throws Exception
{ ServerSocket soc=new ServerSocket(5217);
System.out.println("FTP Server Started on Port Number 5217");
while(true)
System.out.println("Waiting for Connection ...");
transferfile t=new transferfile(soc.accept());
class transferfile extends Thread
Socket ClientSoc;
DataInputStream din;
DataOutputStream dout;
transferfile(Socket soc)
{ try
{ ClientSoc=soc;
din=new DataInputStream(ClientSoc.getInputStream());
dout=new DataOutputStream(ClientSoc.getOutputStream());
System.out.println("FTP Client Connected ...");
System.out.println("External IP of Client ..." + ClientSoc.getInetAddress());
//System.out.println("FTP Client Connected ..." + ClientSoc.getRemoteSocketAddress());
start();
catch(Exception ex)
//encrypto routine starts
class DesEncrypter {
Cipher ecipher;
Cipher dcipher;
// 8-byte Salt
byte[] salt = {
(byte)0xA9, (byte)0x9B, (byte)0xC8, (byte)0x32,
(byte)0x56, (byte)0x35, (byte)0xE3, (byte)0x03 };
// Iteration count
int iterationCount = 19;
DesEncrypter(String passPhrase) {
try {
// Create the key
KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
SecretKey key = SecretKeyFactory.getInstance(
"PBEWithMD5AndDES").generateSecret(keySpec);
ecipher = Cipher.getInstance(key.getAlgorithm());
dcipher = Cipher.getInstance(key.getAlgorithm());
// Prepare the parameter to the ciphers
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
// Create the ciphers
ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
} catch (java.security.InvalidAlgorithmParameterException e) {
} catch (java.security.spec.InvalidKeySpecException e) {
} catch (javax.crypto.NoSuchPaddingException e) {
} catch (java.security.NoSuchAlgorithmException e) {
} catch (java.security.InvalidKeyException e) {
// Buffer used to transport the bytes from one stream to another
byte[] buf = new byte[1024];
public void encrypt(InputStream in, OutputStream out) {
try {
// Bytes written to out will be encrypted
out = new CipherOutputStream(out, ecipher);
// Read in the cleartext bytes and write to out to encrypt
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {
out.write(buf, 0, numRead);
out.close();
} catch (java.io.IOException e) {
public void decrypt(InputStream in, OutputStream out) {
try {
// Bytes read from in will be decrypted
in = new CipherInputStream(in, dcipher);
// Read in the decrypted bytes and write the cleartext to out
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {
out.write(buf, 0, numRead);
//added later on
in.close();
out.close();
} catch (java.io.IOException e) {
} //encryptor routine ends
//not implemented right now as we arent using the ftp server to download stuff...can be activated later on if we want
void SendFile() throws Exception
String filename=din.readUTF();
File f=new File(filename);
if(!f.exists())
dout.writeUTF("File Not Found");
return;
else
{ dout.writeUTF("READY");
FileInputStream fin=new FileInputStream(f);
int ch;
do
ch=fin.read();
dout.writeUTF(String.valueOf(ch));
while(ch!=-1);
fin.close();
dout.writeUTF("File Received Successfully");
String Compare(String filename) throws Exception
///dout.writeUTF("entering compare");
String dateTempString=new String();
Date dateValue=new Date();
SimpleDateFormat formatter = new SimpleDateFormat ("hhmmss");
dateTempString = formatter.format(dateValue);
File dir1 = new File("C:\\FTPnew");
boolean success2 = dir1.mkdir();
if (!success2) {
// Directory creation failed /Already Exists
File dir = new File("C:\\FTPnew\\server");
boolean success = dir.mkdir();
if (!success) {
// Directory creation failed /Already Exists
File ftemp=new File(dir,dateTempString + filename);
File fnewtemp=new File(dir,"new-enc-"+filename);
// Create encrypter/decrypter class
DesEncrypter encrypter = new DesEncrypter("My Pass Phrase!");
FileOutputStream fout=new FileOutputStream(fnewtemp);
int ch;
String temp;
do
{ temp=din.readUTF();
ch=Integer.parseInt(temp);
if(ch!=-1)
fout.write(ch);
}while(ch!=-1);
fout.close();
//dout.writeUTF("written temp en file");
// Decrypt
encrypter.decrypt(new FileInputStream(fnewtemp),
new FileOutputStream(ftemp));
//String Option;
dout.writeUTF("Delete");
System.out.println("File Upload Successfull--Duplicate file with timestamp Created");
boolean success1 = fnewtemp.delete();
return "hello" ;
void ReceiveFile() throws Exception
String ip=din.readUTF();
System.out.println("\tRequest Coming from Internal IP Address : "+ ip);
String filename=din.readUTF();
if(filename.compareTo("File not found")==0)
return;
// Destination directory
File dir11 = new File("C:\\FTPnew");
boolean success22 = dir11.mkdir();
if (!success22) {
// Directory creation failed /Already Exists
File dir = new File("C:\\FTPnew\\server");
boolean success21 = dir.mkdir();
if (!success21) {
// Directory creation failed /Already Exists
File f=new File(dir ,"enc-"+filename);
File fe=new File(dir,filename);
String option;
if(fe.exists())
//dout.writeUTF("File Already Exists");
String compvalue = Compare(filename);
//dout.writeUTF(compvalue);
if(compvalue.compareTo("hello")==0)
//dout.writeUTF("Transfer Completed");
return;
option=din.readUTF();
else
//dout.writeUTF("SendFile");
option="Y";
if(option.compareTo("Y")==0)
// Generate a temporary key.
// Create encrypter/decrypter class
DesEncrypter encrypter = new DesEncrypter("My Pass Phrase!");
FileOutputStream fout=new FileOutputStream(f);
int ch;
String temp;
do
{ temp=din.readUTF();
ch=Integer.parseInt(temp);
if(ch!=-1)
fout.write(ch);
}while(ch!=-1);
fout.close();
// Decrypt
encrypter.decrypt(new FileInputStream(f),
new FileOutputStream(fe));
boolean success2 = f.delete();
dout.writeUTF("Delete");
System.out.println("File Upload Successfull");
else
return;
public void run()
while(true)
try
String Command=din.readUTF();
if(Command.compareTo("SEND")==0)
System.out.println("\tSEND Command Received ...");
ReceiveFile();
continue;
catch(Exception ex)
//System.out.println("\tClient Terminated Abnormally ...........");
continue;Please note that this is not an FTP client and server. FTP is defined by a standard IETF protocol and this isn't it.
Then, move the following lines:
din=new DataInputStream(ClientSoc.getInputStream());
dout=new DataOutputStream(ClientSoc.getOutputStream());
System.out.println("FTP Client Connected ...");
System.out.println("External IP of Client ..." + ClientSoc.getInetAddress());
//System.out.println("FTP Client Connected ..."+ClientSoc.getRemoteSocketAddress());from the constructor into the run() method. i.e. don't do anything with the socket in the thread which handles the accept(). -
Reading .txt file Server side
How do you read a file server side and send it to the client. I am getting confused with FileReader and the fact that you have to wrap a socket with PrintWriter, BufferedWriter and OutputStreamWriter i.e.
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
Any ideasAssuming you want to read from a file on the server and write to a client socket:
FileReader fi= new FileReader("reading.txt");
BufferedReader br= new BufferedReader(fi);
String il=br.readLine();
ServerSocket sock= new ServerSocket(port,mcons);
PrintStream dout=
new PrintStream (sock.getOutputStream());
dout.println(il);
dout.flush();...
Hope this helps. -
We use a real time manufacturing process with our Oracle 8.0.4.0.0 database with NT. Are there any built in apps to duplicate my dbase to my BDC ? What would be that best way to configure a back up server ?
Hi,
The purpose of creating a standby database is quite simple.it used for disaster recovery,suppose your machine is all burnt and the disks all exploded and the standby database is copy of your primary database however you can manually activate youe standby database by shipping all the archived redo logs to standby sited and perform recovery and activate your standy databse manually.the solution of your problem is that if you run out of a space from you tablasepace and if you do not have a space then you can put more hardware to it and if you don't you can also export that tablespace to another user's schema who got more space reserved.once again tell you that primay database is used for varieties of purposes.if you still have a douts you are always welcome.
1. Disaster recoveries.
2. Testing purposes.
3. Can use as an indipended database for reporting
purpose.
thanks... -
Adobe QT32 Server ( ne réponds pas ) ?
Bonjour à tous,
J'ai déjà publier sur ce forum et ça toujours été utile pour moi.
Depuis deux jours, il m'a aussi permis de remédier à de gros soucis, je me permet donc de faire un point avec vous sur les problèmes que j'ai eu bien qu'ils soientt résolue mais en parti seulement... ;(
Je m'explique, je travaille depuis le début de la semaine sur un projet sous avec After Effect assez conséquent puisqu'il contient une centaine de calques. Et donc content de moi, mercredi soir, je lance AE pour effectuer les derniers détails et surtout lancer les exports finaux !
Et là, c'est le drame, AE ne veut plus ouvrir mon projet !
Après quelques recherches sur ce forum et sur le moniteur d'activité pour comprendre je m'aperçois que le processus Adobe QT32 Server semble prendre beaucoup de place dans les calculs lors de l'ouverture. Ni une, Ni deux, je le kill afin de pouvoir ouvrir mon projet. Bien entendu, le projet s'est ouvert mais impossible de faire la liaisons avec mes fichiers .mov...
Puisque ce processus semble remplir ce rôle, donc je continue mes recherches ( il est déja minuit à ce moment là ) et c'est la que je trouve ce type de topic :
http://blogs.adobe.com/aftereffects/2011/02/troubleshooting-quicktime-errors-with-after-ef fects.html
ou
http://blogs.adobe.com/aftereffects/2013/08/solutions-for-problems-with-quicktime-files-in -after-effects-cc-12-0-because-of-conflict-with-dvcprohdvideoout-quicktime-component.html
Je comprends donc qu'il y a des conflits avec modules de quicktime, je decide donc de suivre la procedure et suprimme tout les modules en question ( divx, perian et DVCPROHDVideoOutput.component )
Ainsi que le module Colorisa_II_x64 qui m'empéchait d'ouvrir Adobe Media Encoder CS6...
J'ai aussi re-installé la suite complète CS6 dans le doute...
Il me reste donc comme module Quicktime les suivant :
Et comme magie, AE CS6 ouvre correctement mon projet, ce qui m'a permis d'exporter mon projet sous forme de séquance TIFF mais impossible sous le fomat Quicktime - Apple ProRes 422 ???
Voici l'erreur qu'il me fournie :
J'ai donc réglé le problème d'une autre manière, c'est à dire utiliser une autre machine pour faire mon export .mov ! pour rappel, il est 02h00 du mat' a ce moment là, j'ai donc plus le courage de chercher.
J'ai donc pu livrer mon film à temps, mais comme je suis pas du genre à me laisser faire, après une nuit courte, je continue mes recherches pour comprendre...
Et makgré cela, je reste sans réponse à l'heure actuel...
C'est là que vous allez pouvoir m'aider, enfin je l'espère :
Voici les symptomes que je rencontre :
- Export Quicktime soumis à une forte probabilité d'erreur ( bizarrement plus sur des exports de film de 6 minutes que sur des export de 2 minutes )
- Importation de séquence tiff vraiment longue et propise à un plantage de AE
- et Enfin un processus Adobe QT32 Server qui est toujours en " ne réponds pas "
De même sous Adobe Media Encoder :
Ce qui est vraiment bizarre ce que malgré cela, j'ai pu effectuer des export TIFF sous AE et même des encodages VIMEO et YOUTUBE sous Média Encoder ????
Alors dans l'absolue, tout semble fonctionner mais tout reste vraiment instable dans l'ensemble et lent...
Donc voici m'a question après avoir raconté ma vie :
Est ce quelqu'un aurez un avis ? une solution ? ou rencontre le même probleme ?
D'avance merci d'avoir lu mon post et prendre un peu de temps pour que l'on puisse ensemble trouver la solution.
A+
Fabien,
Voici ma configuration si besoin :Je me permet de rajouter un point sur ce sujet.
Après plusieurs tests, il s'avère que je ne peux plus effectuer d'export Apple ProRes 422 à partir d'AE CS6 !
Voici le message d'erreur que j'ai encore eu ce matin :
Je pense que cela vient d'un conflit entre Adobe QT32 Server et Quicktime ? mais j'ai beau regarder un peu partout dans les forums et suivre les procedures décrites, je n'arrive pas à régler ce problème ?
Est ce que quelqu'un a le même probleme ?
D'avance merci
A+
Fabien, -
Hi i have done VO Extension but how to deployee to server
Hi
I have one custom page i have add two clumns in exsting VOquery and that query paste at same VO and i have create two items in that page and asign viewInstance & Viewattribute
1)i have one doute how to deployee into server
2) witch Import statement we will run
3) which files i will deployee into server or all files are need deployee
Please tell me and hell meAfer deploy the Vo.xml VoRowImpl VoImpl and run the page i am getting this error please tell me how to resolve
oracle.apps.fnd.framework.OAException: oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.lang.NoSuchMethodError, msg=val.oracle.apps.per.selfservice.occh.server.PersonVOImpl.initQuery(Ljava/lang/String;)V
at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:891)
at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:867)
at oracle.apps.fnd.framework.OAException.wrapperInvocationTargetException(OAException.java:988)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:211)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:153)
at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(OAApplicationModuleImpl.java:750)
at val.oracle.apps.per.selfservice.occh.server.webui.MedAssessHistCO.processRequest(MedAssessHistCO.java:66)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:587)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processRequest(OAPageLayoutHelper.java:1136)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processRequest(OAPageLayoutBean.java:1569)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processRequest(OAFormBean.java:385)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processRequest(OABodyBean.java:353)
at oracle.apps.fnd.framework.webui.OAPageBean.processRequest(OAPageBean.java:2360)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1759)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:511)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:432)
at oa_html._OA._jspService(_OA.java:84)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
at oracle.jsp.JspServlet.service(JspServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at oracle.jsp.provider.Jsp20RequestDispatcher.forward(Jsp20RequestDispatcher.java:162)
at oracle.jsp.runtime.OraclePageContext.forward(OraclePageContext.java:187)
at oa_html._OA._jspService(_OA.java:94)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
at oracle.jsp.JspServlet.service(JspServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
at org.apache.jserv.JServConnection.run(JServConnection.java:294)
at java.lang.Thread.run(Thread.java:619)
## Detail 0 ##
java.lang.NoSuchMethodError: val.oracle.apps.per.selfservice.occh.server.PersonVOImpl.initQuery(Ljava/lang/String;)V
at val.oracle.apps.per.selfservice.occh.server.MedAssessHistAMImpl.initSearch(MedAssessHistAMImpl.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:190)
at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(OAUtility.java:153)
at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(OAApplicationModuleImpl.java:750)
at val.oracle.apps.per.selfservice.occh.server.webui.MedAssessHistCO.processRequest(MedAssessHistCO.java:66)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:587)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processRequest(OAPageLayoutHelper.java:1136)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processRequest(OAPageLayoutBean.java:1569)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processRequest(OAFormBean.java:385)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:959)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequestChildren(OAWebBeanHelper.java:926)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processRequest(OAWebBeanHelper.java:646)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processRequest(OAWebBeanContainerHelper.java:247)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processRequest(OABodyBean.java:353)
at oracle.apps.fnd.framework.webui.OAPageBean.processRequest(OAPageBean.java:2360)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1759)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:511)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:432)
at oa_html._OA._jspService(_OA.java:84)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
at oracle.jsp.JspServlet.service(JspServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at oracle.jsp.provider.Jsp20RequestDispatcher.forward(Jsp20RequestDispatcher.java:162)
at oracle.jsp.runtime.OraclePageContext.forward(OraclePageContext.java:187)
at oa_html._OA._jspService(_OA.java:94)
at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java:119)
at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java:417)
at oracle.jsp.JspServlet.doDispatch(JspServlet.java:267)
at oracle.jsp.JspServlet.internalService(JspServlet.java:186)
at oracle.jsp.JspServlet.service(JspServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at org.apache.jserv.JServConnection.processRequest(JServConnection.java:456)
at org.apache.jserv.JServConnection.run(JServConnection.java:294)
at java.lang.Thread.run(Thread.java:619) -
hi friens
small doutes plz replay in bref.
1 what is convertional routine?
2 diff between search help and match code?
3 best way to solve nested select statement?
4 what is t.code for application server?
5 easy way to handle table control in bdc?
6 best method to performe the report?
7 in alv to print footer wht is the process?
8 if we have both dev and testing in same sys wht is the process to transport?
9 what is version magement?
10 in interactive repoting hide area for all list same r for each list they will be seprate?
11 wht is the process to use lock object?
12 how to debugg a smart form?
13wht will happen when we use stop in prog?
14if we find a error in bdc what will be the sy-subrc?
while we r doing bdc if suddenly power failure what will happens?
15 what is the process to handle multiple transtions in bcd session?
16 i what to learn smart forms & bapi & ale ,idocs what is easy why to learn quickly?hi Sunil,
All your queries fall in to this check them out
Common Links
http://www.sappoint.com/abap.html
http://www.sap-img.com/abap-function.htm
http://www.easymarketplace.de/online-pdfs-q-s.php
http://help.sap.com/
http://sapassist.com/groups/groups.asp?v=sap-r3-dev&m=3&y=2004
http://training.saptechies.com/sap-basis-certification-sample-questions/
http://www.geocities.com/mpioud/Abap_programs.html
http://cma.zdnet.com/book/abap/index.htm
http://www.sapdevelopment.co.uk/
http://www.sap-img.com/
http://juliet.stfx.ca/people/fac/infosys/abap.htm
http://help.sap.com
http://www.sap-img.com
http://www.thespot4sap.com
http://www.sap-basis-abap.com/
http://www.sapdevelopment.co.uk/
http://www.sap-img.com/
http://juliet.stfx.ca/people/fac/infosys/abap.htm
http://help.sap.com/saphelp_46c/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_46c/helpdata/en/d6/0db357494511d182b70000e829fbfe/frameset.htm
http://www.henrikfrank.dk/abapexamples/SapScript/sapscript.htm
http://www.sapgenie.com/abap/example_code.htm
http://www.geocities.com/SiliconValley/Campus/6345/abapindx.htm
http://help.sap.com/printdocu/core/Print46c/en/Data/Index_en.htm
http://help.sap.com/saphelp_40b/helpdata/en/4f/991f82446d11d189700000e8322d00/applet.htm
http://www.sap-img.com/abap-function.htm
http://www.sapgenie.com/abap/code/abap19.htm
http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
http://www.planetsap.com/Tips_and_Tricks.htm
http://help.sap.com/saphelp_40b/helpdata/ru/d6/0dc169494511d182b70000e829fbfe/applet.htm
http://www.henrikfrank.dk/abapexamples/SapScript/symbols.htm
http://www.henrikfrank.dk/abapexamples/index.html
http://sap.ittoolbox.com/documents/document.asp?i=752
http://members.aol.com/_ht_a/skarkada/sap/
http://sappoint.com/abap/
http://members.tripod.com/abap4/SAP_Functions.html
http://members.ozemail.com.au/~anmari/sap/index.html
http://www.planetsap.com/Userexit_List.htm
http://www.planetsap.com/Tips_and_Tricks.htm
http://www.kabai.com/abaps/q.htm
http://www.planetsap.com/Userexit_List.htm
http://help.sap.com/saphelp_bw21c/helpdata/en/c4/3a8090505211d189550000e829fbbd/frameset.htm
http://www.sapgenie.com/abap/bapi/example.htm
http://help.sap.com/saphelp_45b/helpdata/en/65/897415dc4ad111950d0060b03c6b76/content.htm
http://www.sap-basis-abap.com/index.htm
http://help.sap.com/saphelp_40b/helpdata/en/fc/eb2c46358411d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_46c/helpdata/en/aa/aeb23789e95378e10000009b38f8cf/frameset.htm
http://www.geocities.com/ResearchTriangle/1635/system.html
http://www.sapdesignguild.org/resources/MiniSG/3_Managing/3_Functions_Table_Control.htm
http://help.sap.com/saphelp_45b/helpdata/en/d1/801bdf454211d189710000e8322d00/content.htm
http://www.sapfans.com/sapfans/repos/saprep.htm
http://www.planetsap.com/howdo_a.htm
http://help.sap.com/saphelp_util464/helpdata/en/69/c2516e4ba111d189750000e8322d00/content.htm
http://www.sapgenie.com/abap/smartforms_detail.htm
http://www.sap-img.com/abap.htm
http://help.sap.com/saphelp_46c/helpdata/en/fc/eb2d67358411d1829f0000e829fbfe/content.htm
http://www.geocities.com/victorav15/sapr3/abap.html
http://www.henrikfrank.dk/abapexamples/SapScript/sapscript.htm
http://abap4.tripod.com/Other_Useful_Tips.html
http://help.sap.com/saphelp_45b/helpdata/en/cf/21ee2b446011d189700000e8322d00/content.htm
http://www.sap-basis-abap.com/sapmm.htm
http://sap.ittoolbox.com/nav/t.asp?t=303&p=448&h1=303&h2=322&h3=448
http://sapfans.com/
http://cma.zdnet.com/book/abap/ch03/ch03.htm
http://help.sap.com/saphelp_40b/helpdata/en/4f/991f82446d11d189700000e8322d00/applet.htm
http://sappoint.com/abap/
http://www.henrikfrank.dk/abapuk.html
http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm
http://www.sapgenie.com/abap/index.htm
http://www.sap-img.com/abap.htm
http://www.sapdevelopment.co.uk/tips/tipshome.htm
http://help.sap.com/printdocu/core/Print46c/en/Data/Index_en.htm
http://sap.ittoolbox.com/nav/t.asp?t=322&p=322&h1=322
http://sap.ittoolbox.com/nav/t.asp?t=448&p=448&h1=448
http://www.thespot4sap.com/
http://www.kabai.com/abaps/q.htm
http://www.geocities.com/mpioud/Abap_programs.html
http://www.sapgenie.com/abap/tips_and_tricks.htm
http://www.sapassist.com/code/d.asp?whichpage=1&pagesize=10&i=10&a=c&o=&t=&q=&qt=
ABAP System Fields
http://help.sap.com/saphelp_46c/helpdata/en/7b/fb96c8882811d295a90000e8353423/content.htm
For FAQ
http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
http://www.sapgenie.com/faq/abap.htm
BAPI-step by step
http://www.sapgenie.com/abap/bapi/example.htm
Weblog for receive email and processing it through ABAP
/people/thomas.jung3/blog/2004/09/09/receiving-e-mail-and-processing-it-with-abap--version-610-and-higher
For Logical database
http://help.sap.com/saphelp_46c/helpdata/en/9f/db9bed35c111d1829f0000e829fbfe/frameset.htm
very useful
http://help.sap.com/saphelp_46c/helpdata/EN/35/2cd77bd7705394e10000009b387c12/frameset.htm
Useful link to websites
http://www.hernangn.com.ar/sap.htm
Useful for background
http://www.sappoint.com/basis/bckprsng.pdf
http://help.sap.com/saphelp_nw04/helpdata/en/6f/08703713bf277ee10000009b38f8cf/frameset.htm
http://publib.boulder.ibm.com/infocenter/wbihelp/index.jsp?topic=/com.ibm.wbix_adapters.doc/doc/mysap4/sap4x41.htm
Table control in BDC
http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm
BDC
http://www.sap-img.com/bdc.htm
For posting weblog,
/people/sap.user72/blog/2005/06/28/sdn-weblogs-making-it-easier
Dynamic Internal table -weblog in sdn
/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table
Smartforms
http://www.sap-basis-abap.com/sapsf001.htm
http://www.sap-press.com/downloads/h955_preview.pdf
http://www.ossincorp.com/Black_Box/Black_Box_2.htm
http://www.sap-img.com/smartforms/sap-smart-forms.htm
SapScript
http://www.sap-img.com/sapscripts.htm
http://sappoint.com/abap/
http://www.henrikfrank.dk/abapexamples/SapScript/sapscript.htm
How to trace smartform
http://help.sap.com/saphelp_47x200/helpdata/en/49/c3d8a4a05b11d5b6ef006094192fe3/frameset.htm
Mail
http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html
http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp
http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
http://www.sap-img.com/abap/sending-email-with-attachment.htm
BOM Explosion
/people/prakash.singh4/blog/2005/05/15/explode-boms-in-enterprise-portal-using-htmlb-tree--part-1-abap
BOM
http://help.sap.com/saphelp_erp2005/helpdata/en/ea/e9b7234c7211d189520000e829fbbd/frameset.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/d1/2e4114a61711d2b423006094b9d648/frameset.htm
http://www.sap-img.com/sap-sd/sales-bom-implementation.htm
http://www.sap-basis-abap.com/sappp007.htm
OLE
http://www.sapgenie.com/abap/ole.htm
http://help.sap.com/saphelp_46c/helpdata/en/59/ae3f2e488f11d189490000e829fbbd/frameset.htm
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIOFFI/BCCIOFFI.pdf
http://help.sap.com/saphelp_47x200/helpdata/en/59/ae3cac488f11d189490000e829fbbd/content.htm
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE6/BCFESDE6.pdf
ALVGRID with refresh
http://www.geocities.com/mpioud/Z_DEMO_ALV_REFRESH_BUTTON.html
ALV Group Heading
http://www.sap-img.com/fu037.htm
http://www.sap-img.com/abap/test-alv-display-with-header-footer.htm
http://www.sap-img.com/abap/sample-alv-heading-in-alv.htm
ALV all Imp
http://www.geocities.com/mpioud/Abap_programs.html
http://www.sap-img.com/fu002.htm
http://www.sapdevelopment.co.uk/reporting/alvhome.htm
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_events.htm
ALV Documentation for Field
http://www.mpls.k12.mn.us/sites/f7071225-9844-4da6-96c0-996b9c74b221/uploads/SAP_Navigation_Training2.ppt
Regards,
Santosh -
WL6.0 server start - socket error
Hi,
I was trying to start my example and petstore server, I got the following
message while starting it, and it shut down after if found that something
might be using the socket. Can anyone help me with this? Thanks.
<Jan 18, 2001 1:19:38 AM PST> <Notice> <Management> <Loading configuration
file .\config\examples\config.xml ...
>
<Jan 18, 2001 1:19:42 AM PST> <Info> <Logging> <Only log messages of
severity "Error" or worse will be displayed
in this window. This can be changed at Admin Console> examples> Servers>
examplesServer> Logging> Debugging> St
dout severity threshold>
<Jan 18, 2001 1:20:15 AM PST> <Notice> <WebLogicServer> <WebLogic Server
started>
<Jan 18, 2001 1:20:15 AM PST> <Emergency> <WebLogicServer> <Unable to create
a server socket for port: 7002. jav
a.net.BindException: Address in use: JVM_Bind Perhaps another process is
using port 7002.>
<Jan 18, 2001 1:20:15 AM PST> <Emergency> <WebLogicServer> <Unable to create
a server socket for port: 7001. jav
a.net.BindException: Address in use: JVM_Bind Perhaps another process is
using port 7001.>
<Jan 18, 2001 1:20:15 AM PST> <Emergency> <WebLogicServer> <The WebLogic
Server is no longer listening for conne
ctions. You should probably restart it.>
<Jan 18, 2001 1:20:15 AM PST> <Emergency> <WebLogicServer> <The WebLogic
Server is no longer listening for conne
ctions. You should probably restart it.>On Tue, 30 Aug 2005 13:01:37 -0700, Merline Sigamani <> wrote:
Could someone tell me why I would be getting this error?
How can I figure out which port is being used and which are free? I checked the /etc/services I didn't see 8001 listed there, so why this conflict?
Please help. Any suggestion would be appericiated.
thanks
merline
####<Aug 30, 2005 12:53:19 PM CDT> <Emergency> <WebLogicServer> <sunserv3> <STAp
p1> <ListenThread.Default> <<WLS Kernel>> <> <BEA-000350> <Unable to create a se
rver socket on Channel Default for: 10.200.110.51, port: 8001. java.net.BindExce
ption: Cannot assign requested address Perhaps the address 10.200.110.51 is inco
rrect or another process is using port 8001.>
####<Aug 30, 2005 12:53:20 PM CDT> <Emergency> <Security> <sunserv3> <STApp1> <m
ain> <<WLS Kernel>> <> <BEA-090085> <Server failed to bind to the configured por
t. The port may already be used by another process.>
####<Aug 30, 2005 12:53:20 PM CDT> <Emergency> <WebLogicServer> <sunserv3> <STAp
p1> <main> <<WLS Kernel>> <> <BEA-000342> <Unable to initialize the server: Serv
er failed to bind to the requested port. See preceeding log message for details.
>well you can can download a tool if you are on windows (I use one called tcp
view) or maybe zone alrm would tell you what ports are being used already.
You can see what processes are using what ports then easily. I am not sure
what to use on other os's.
Also, you might not care, just set your system to use say port 8002 instead of
8001 and see if that works / is open.
Good Luck,
Jeff -
Need help with certain bit of server code
i am making a chat messenger and are having trouble with this part, i have created outputstreams as a hashtable, i hope thats correct.. the problem is it wont call up the serverThread.. is there and easier way using static variables so it doesnt have to pass the parameters? any ideas..
// Create a DataOutputStream for writing data to the
// other side
DataOutputStream dout = new DataOutputStream(s.getOutputStream());
// Save this stream so we don't need to make it again
// Hashtable outputstreams = new Hashtable();
outputStreams.put(s, dout);
// Create a new thread for this connection, and then forget
// about it
new ServerThread(this, s);
static void ServerThread(Server server,Socket socket) {
// Save the parameters
this.server = server;
this.socket = socket;
// Start the thread
start();
}This application is in functional state. The only thing which
is not working is "send private message". Gui is there and functionality
is also there but I dont have time to put it together.
There is a readme file inculded in the zip file PLEASE READ THE FILE BEFORE RUNNING THE APPLICATION
Dont complain for dirty code. -
Runtime exception in a multiple file sending client server program ?
hi I have the following program for one client and one server.
import java.io.*;
public class FileTransferRoutines{
private int BUFFER = 2048;
private String LastFileRecieved;
private long sendRestart;
private long recieveRestart;
public void setSendBufferSize(int size)
BUFFER = size;
public void setRecieveBufferSize(int size)
BUFFER = size;
public void storeRawStream(DataInputStream in, String tempDir, long restart) {
try {
RandomAccessFile fileOut;
int fileCount = in.readInt();
for(int i=0; i<fileCount; i++) {
byte data[] = new byte[BUFFER];
String fileName = in.readUTF();
fileOut = new RandomAccessFile(tempDir+"\\"+fileName,"rws");
long fileLength = in.readLong();
if(i==0 && restart != 0)
fileOut.seek(restart);
long base = restart/(long)BUFFER;
long offset = restart - base*(long)BUFFER;
for(int j=(int)base; j<fileLength / BUFFER; j++) {
int totalCount = 0;
if(j==(int)base)
totalCount = (int)offset;
while(totalCount < BUFFER) {
int count = in.read(data, totalCount, BUFFER - totalCount);
totalCount += count;
recieveRestart += (long)count;
fileOut.write(data, 0, totalCount);
else
for(int j=0; j<fileLength / BUFFER; j++) {
int totalCount = 0;
while(totalCount < BUFFER) {
int count = in.read(data, totalCount, BUFFER - totalCount);
totalCount += count;
recieveRestart +=(long)count;
fileOut.write(data, 0, totalCount);
// read the remaining bytes
int count = in.read(data, 0, (int) (fileLength % BUFFER));
recieveRestart += (long)count;
fileOut.write(data, 0, count);
fileOut.close();
LastFileRecieved = fileName;
recieveRestart = 0;
} catch (Exception ex) {
ex.printStackTrace();
private File[] makeFileList(String TempDir)
File dir = new File(TempDir);
File files[];
files = dir.listFiles();
return files;
public void sendFiles(String dir, DataOutputStream out,
String lastFileSent, long restart) throws IOException {
byte data[] = new byte[BUFFER];
File files[] = makeFileList(dir);
RandomAccessFile fileInput;
if(lastFileSent == null)
out.writeInt(files.length);
for(int i=0; i<files.length; i++) {
// send the file name
out.writeUTF(files.getName());
// send the file length
out.writeLong(files[i].length());
fileInput = new RandomAccessFile(files[i],"r");
int count = 0;
while((count = fileInput.read(data) )!= -1) {
out.write(data, 0, count);
sendRestart = sendRestart + (long)count;
fileInput.close();
sendRestart = 0;
else{
int lastFileIndex = 0;
for(int j=0 ; j<files.length; j++){
if(lastFileSent.equals(files[j].getName()))
lastFileIndex = j;
out.writeInt(files.length-lastFileIndex);
for(int i=lastFileIndex+1; i<files.length; i++) {
// send the file name
out.writeUTF(files[i].getName());
// send the file length
out.writeLong(files[i].length());
fileInput = new RandomAccessFile(files[i],"r");
if(i==lastFileIndex+1)
fileInput.seek(restart);
int count = 0;
while((count = fileInput.read(data)) != -1) {
out.write(data, 0, count);
sendRestart = sendRestart + (long)count;
fileInput.close();
sendRestart = 0;
out.flush();
public long getRecieveRestart()
return recieveRestart;
public long getSendRestart()
return sendRestart;
public String getLastFileRecieved()
return LastFileRecieved;
public void setRecieveRestart(long value)
recieveRestart = value;
public void setSendRestart(long value)
sendRestart = value;
import java.io.*;
import java.net.*;
public class TransferServer implements Runnable {
private int serverPort;
private volatile boolean closeServer = false ;
private volatile boolean fileSend = false;
private volatile boolean directorySend = false;
private volatile long sendRestart = 0;
private volatile String fileName = null;
private volatile String dirName = null;
private volatile String lastFileSent = null;
private volatile FileTransfer ftp;
//private volatile FileTransferRoutines ftrp;
private ServerSocket server;
TransferServer(int port)
serverPort = port;
try{
server = new ServerSocket(serverPort);
}catch(IOException ioe)
ioe.printStackTrace();
ftp = new FileTransfer();
//ftrp = new FileTransferRoutines();
public void closeConnection()
closeServer = true;
public void setSendRestart(long restart)
ftp.setSendRestart(restart);
sendRestart = restart;
public void setFileToSend(String FileName)
clearDirectoryToSend();
fileSend = true;
fileName = FileName;
public void clearFileToSend()
fileSend = false;
fileName = null;
public void setDirectoryToSend(String DirName)
clearFileToSend();
directorySend = true;
dirName = DirName;
public void clearDirectoryToSend()
directorySend = false;
dirName = null;
public void setLastFileSent(String fileName)
lastFileSent = fileName;
public void run()
Socket sock;
try{
while(!closeServer)
sock = server.accept();
try{
if(fileSend && !directorySend)
RandomAccessFile raf = new RandomAccessFile(fileName , "r");
ftp.sendFile(raf,sock.getOutputStream(),sendRestart);
ftp.setSendRestart(0);
sendRestart = 0;
sock.close();
clearFileToSend();
else if(directorySend && !fileSend)
DataOutputStream dout = new DataOutputStream(sock.getOutputStream());
FileTransferRoutines ftrp = new FileTransferRoutines();
ftrp.setSendBufferSize(sock.getSendBufferSize());
long restart = ftrp.getSendRestart();
ftrp.sendFiles(dirName,dout,lastFileSent,restart);
sock.close();
clearDirectoryToSend();
}else
sock.close();
catch(FileNotFoundException foe)
foe.printStackTrace();
catch(IOException ioe)
ioe.printStackTrace();
}catch(IOException ioe)
ioe.printStackTrace();
public class TransferServerTest {
public static void main(String[] args) {
TransferServer ttc = new TransferServer(4444);
ttc.setDirectoryToSend("C:\\testFolder\\folder1\\");
Thread fileTransferServer = new Thread(ttc,"fileserver");
fileTransferServer.start();
import java.io.*;
import java.net.*;
public class TransferClient {
public static void main(String[] args) {
String dir = "C:\\testFolder\\folder2\\";
Socket sock = null;
try{
sock = new Socket("localhost",4444);
}catch(IOException ioe)
System.out.println("Could not connect to server");
try{
FileTransferRoutines ftrp = new FileTransferRoutines();
ftrp.setRecieveBufferSize(sock.getReceiveBufferSize());
DataInputStream din = new DataInputStream(sock.getInputStream());
ftrp.storeRawStream(din,dir,0);
}catch(IOException ioe)
ioe.printStackTrace();
this code works fine for the first connection of the client The client then automatically disconnects after the transfer is complete.
when i reconnect the client by rerunning the TransferClient code
it gives the following exception java.io.EOFException
at java.io.DataInputStream.readInt(Unknown Source)
at FileTransferRoutines.storeRawStream(FileTransferRoutines.java:24)
at TransferClient.main(TransferClient.java:19)
i just cant understand where that eof comes from
please help!!!!
Edited by: danish.ahmed.lnmiit on Jan 21, 2008 7:18 PMi was not closing my DataInputStream and also cleaned up my code and problem got solved
Maybe you are looking for
-
Mac OS X Server: the best option?
We are an expanding small design/web creation business moving soon from 6 to 9 team members. Workstations are all stand-alone in terms of software, which ranges from Office X to full Macromedia Studio suite etc. running over a wireless 11g network an
-
Hi I am into house music and I cannot work out how to print a playlist so that the title, artist, mix and length of tune is showing. I usually use CD Jewel case insert and I can only usually see either 1.) the title + Artist+ and half the mix or 2.)
-
New Imac generates thumbnails that I can't see on my powermac running OS 10.4.11
Images created on my new Imac OS 10.8.2 can be copied accross to my Powermac G5 OS 10.4.11 but the thumbnail is missing. Is there a setting that I need to unlock to allow the older mac to see these thumbnails?
-
New to ipad and searched for paprika app. clicked on one and downloaded. After doing so, I realized it was an app for the i phone instead of the I pad. Are they interchangeable - can i use this i phone app on my ipad or can i exchange?
-
Failed to install Important Updates
Error Code 0x8007045D afetr failing to install updates via SCCM/SMS