Designing table for client/server situation ....

I am designing table that will be accessed by concurrent users. It's structure is given below:
AccountID number(30) Primary Key
AccountName text(50)
I have a sequence named: "seqAccID" which increments AccountID and stores new ID.
I want to know what changes must be done in the table so that if concurrent users are creating entering in the same table and press enter at the same time there is no possibility of error: "Primary Key violation".

I have a sequence named: "seqAccID" which increments
AccountID and stores new ID.
I want to know what changes must be done in the table
so that if concurrent users are creating entering in
the same table and press enter at the same time there
is no possibility of error: "Primary Key violation".You don't need anything, sequences guarantee the uniqueness (that's their purpose). See http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#sthref883
If you use your own counter instead, then the For Update suggestion is correct.

Similar Messages

  • Help-Is 9ias a necessity even for client server deployment of forms6i

    Hi
    Is 9Ias a necessity even for client server deployment of forms6i using developerSuite. I have been told that Oracle no longer markets Forms Server?
    Ganesh.

    No for client server deployment you don't need iAS.
    On the second issue Forms server (the bit of forms used to web deploy) is no longer sold stand-alone - it is part of the iAS suite.

  • How's this partition table for my server?

    How's this partition table for my server?  Web/DNS/DHCP/Mail Server.
    hdd1: ~8gb total
    /boot - 100mb
    swap - 1gb
    / - rest of drive
    hdd2: ~155gb total
    /var - whole drive
    This is a Compaq ProLiant 5500 server with 10 drives.  Will most things be installed inside /var or what?

    Zetsumei wrote:Web/DNS/DHCP/Mail Server.
    Web = /srv
    DNS = /var
    DHCP = /var
    Mail = Depends which package you use. I use postfix and told it to use /srv
    I would half your swap, reduce /var and put the extra space into /srv
    Also create a separate /tmp and /home to prevent accidental or deliberate DoS attacks by filling your / partition
    Here's what I use on my Web / DNS / FTP server:
    Filesystem Size Used Avail Use% Mounted on
    /dev/xvda 493M 176M 317M 36% /
    /dev/xvdc 31M 674K 29M 3% /boot
    /dev/lvmData-home 62M 26M 34M 44% /home
    /dev/lvmData-usr 2.0G 848M 1.1G 45% /usr
    /dev/lvmData-tmp 496M 20M 451M 5% /tmp
    /dev/lvmData-srv 1.5G 769M 667M 54% /srv
    /dev/lvmData-var 496M 231M 241M 49% /var
    /dev/lvmData-pacman 384M 303M 82M 79% /var/cache/pacman
    /dev/lvmData-backup 5.5G 4.6G 565M 90% /mnt/backup

  • How do we populate the SIGN_POST table for routing server

    Hi,
    How do we populate the SIGN_POST table for routing server…? We having the Street data network... we have populated the NODE, EDGE and PARTITION tables from street data. Is there any procedure available for populating the SIGN_POST table from street data? ARE there any predefined methods available?
    Thanks and Regards
    Aravindan

    This data has to come from the data provider.
    There are no procedures to populate this information, if this
    data is not available for your data set.
    For example, NAVSTREETS from NAVTEQ has this data as part
    of their street network data.
    siva

  • Do I need to install Oracle database 12c on PC to create tables for Weblogic server

    Hi,
    I am new to WebLogic and I am following a book Java EE Development
    with Eclipse published by PACKT Publishing to learn  Java EE.  I have installed Oracle Enterprise Pack for Eclipse
    on the PC and I am able to log into the WebLogic Server
    Administration Console and set up a Data Source.  However the next step is to create
    tables for the database.  The book says that the tables can be
    created using SQL script run from the SQL command line.
    I cannot see any way of inputting SQL script into the WebLogic
    Server Admistration Console.  Aslo there is no SQL Command line
    in DOS.
    I have put a previous question on the Oracle Forum about the above and I  was advised to use SQL Plus
    to create the tables for the weblogic server but no mention was made of installing Oracle database.
    I have downloaded InstantClient SQL Plus and Instantclient Basic on a PC and
    put the files into the same directory C:\SQLPlus but now I am having a problem in that it is
    looking for a username and password when I run the sqlplus.exe file.
    Now I assume that I need to have an installation of Oracle databse on the
    PC so as to be able to use SQL Plus.  Am I correct in this or can I create tables for the
    datasource in weblogic without an Oracle database?
    Thanks in advance for your help. Brian

    You should install it separately and also need to change the OBIEE's user.sh to tell it where is your Oracle client installed.

  • JavaFX as a SaaS/ How good is it for Client-Server work?

    I was under the impression that FX could be used to produce a Client-Server application as well as SaaS.
    a member of another forum said "I'm sure you meant to say "Desktop". JavaFX will not be making inroads on the web as a client-side technology."
    To which I said
    There have been examples of FX used with EE
    http://www.oracle.com/technetwork/java/javafx/samples/index.html
    http://docs.oracle.com/javafx/2/overview/jfxpub-overview.htm
    Sales Dashboard (DataApp)
    DataApp is a client-server application for a fictional global automobile company called Henley Car Sales. Automobile sales are simulated on an EJB server using JavaDB, and the data is available via Derby and a RESTful web service. The client demonstrates a variety of data presentations by using a mix of FXML and JavaFX.
    I thought originally that JavaFX was "Desktop" only also, until I found this example. I couldn't get it to run due to some weird Database line read issue that others also had. I'm not sure if this is now due to FX's integration, or if this was something new, but I believe I have seen another FX client-server app as well.
    I'm not that familiar with the client-server side of Java yet, so if you have other Information I would like to know, because I am looking to design a Client-Server app with FX, and I don't see why it would be an issue, unless there are huge limitations."
    He ended up saying "Those are still desktop apps. Sure, they are client-server in that they connect to a remote database. But they are still traditional fat-client apps rather than web-based thin-client SAAS web applications which, these days, most people will think of when you say "client".
    My point is to be more precise when you use the word "client".
    But if your point is just that JavaFX is taking over from Swing for the limited areas in which Swing is used, I have no insight into that area."
    Now I don't really like attitudes when I get my question answered, but the high and mighty needs to stop. It clearly says Client-Server so I don't know why it's being denounced by this dude who thinks he obviously knows better.
    Anyways he talks about it only being able to connect to a DB, to which it says it uses EE tech such as EBJ, Restful, and Derby, so that's more than just DB right(I don't know since I havent' learned that yet)?
    It seems as if he's saying that only EE code can go up on a server? Or can SE code go up there as well?
    I'm looking to design a SaaS software with FX, so if this isnt' possible I would like to know possible other options(or just having all of the gui work on the client, and the rest on the backend)???
    Thanks!
    ~KZ
    Edited by: KonradZuse on Apr 30, 2013 11:26 AM

    This response is not a tutorial, I hope it gives you some verbiage to use in further searches.
    SaaS to me means that the service is running on the server. If you have the server and permission to run java apps there then you can use Java FX by having the server shuttle requests to the Java FX app. But this is probably not the intent of Saas (it would be more appropriate to use a java implemented web service).
    If you are using Netbeans then it is very easy to create demo projects; use "File/New Project" to run them on your local computer.
    Example File/New Project/Java Web/Web Application will give you a hello world web site very quickly. This will 1) start either tomcat or glassfish as the server. 2) launch an html page with "hello world". then you can use java script to talk with the server via ajax. Using this approach you are going to need to study JSP or J2EE stuff.
    After this is running you could start one of the Java Fx examples in Netbeans: File / New Project / Samples / WebViewBrowser. This will start a javaFX app that acts like a browser and runs on the client.
    So, start the "hello world" app in netbeans by right clicking it in the project pain and selecting "debug". Then start the webviewBrowser app the same way to load that web page that has "hello world" in it as all browsers do. In the WebviewBrowser (which is java fx) you can get at the javascript in the web page and do all kinds of stuff. You'll need to search for webviewBrowser examples.
    The above all assumes a Netbeans solution. But, as you probably know, there are no rules. The server can be in C++ and the client in C (or any other language). The server and client usally communicate via http or tcp. So you could have a server written in java (maybe J2ee or you can rewrite a http server from scratch which isn't that hard - search for "HttpServletRequest and HttpSession" ) and the client can be in Java FX (where the Java FX talks directly with the server via http (no javascript or web page in the middle) again there are probably hundreds of libraries to talk to a http server).
    I use HttpServletRequest and HttpSession on the server side with MySQL and xml. On the client I use javaScript but I am moving to a strictly Java FX solution. This will give me close to 100% java on both sides and for my purposes this will work. (I may need a little html in the middle for drag and drop installation.) I am hoping that work continues with porting Java FX to most devices: Android, IOS, WinPhone. It is already on Linux, Windows Desktops and Mac.
    Edited by: KevinPas on May 1, 2013 9:50 AM
    Edited by: KevinPas on May 1, 2013 9:56 AM

  • Framework for client-server Architecture in Java !!!! With swing

    Hi,
    Considering the scenario where we are having the Client-Server application and the rich clients at the client place , based on the frames.I have though of the logic as :
    Client -----------> ClientComponentframeWorkObject(Genric Objects) ---------> reading the data from the configurable files to find where to take the user action ---------> will call the Servercomponetobject(Generic objects) can be Servlet or just a object which connects to the server(DB).I have been able to find the open-source frame work at the Apache ,all covering the server-side framework so i though of doing some work with the framework covering the client(swing) -server Archetect.Even I dont know how the existing server side framework support the swing client.
    I would appericiate if someone who had worked on the client server requirement with java , could share the knowledge about the framework being used in the existing work.
    regards
    Vicky

    Hi,
    GENERIC CLIENT COMPONENT:
    package com.nst.clientcomp;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public abstract class ClientComp extends JFrame
      protected JFrame currentframe;     
      protected JPanel  panel;
      public ClientComp()
           // To decide if the ClientComp to be Frame or the Panel.
        //panel=this;     
        //currentframe=new JFrame();
        panel=new JPanel();     
        currentframe=this;
      // Just Concentrate on the GUI , look and feel here .......And the user action will generate
      // generate the event which should call the callNextView()..The component developer have to
      // concentrate on the writing the display() and the callNextView()..
      public abstract void display() ;
      // This is the Final action.Template Pattern being Called
      public String action()
           readServerObj();
           processContent();
           display();              
           return null;
       Reading of the value object which is being Passes from the Server.As per the Design it is
       called VOFS and will be read here.Here
       1) Connect to the Server
       2) Pass the VOFC through the socket connection
       3) Also obtain the VOFS(Value object from server) 
       In certain application it can be implemented here
      public Object readServerObj()
            System.out.println("Hello from ServerObj!!! Should be implemented ");
            return null;
       Processing the Sever Value Object, which is basically as VOFS.It is processed by the
       Client.And infact the Value object from Client(VOFC) should be generated here for next
       user interaction from the Client.
      public void processContent()
            System.out.println("Hello from processContent !!! Should be implemented ");
      // Clear the Frame
      private void cleanUp()
         currentframe.dispose();
         Contains the place where next view takes.Before this is invoked the cache copy of the
         StateObject should be stored in the appropriate Data Structure......      
      public void callNextView(ClientComp com)                     
            panel.removeAll();
            com.action();
            cleanUp();
    }   COMONENTS AS PER THE FRAMEWORK :
    package com.nst.clientcomp;
    import javax.swing.*;
    import java.awt.event.*;
    public class Comp1 extends ClientComp implements ActionListener
      JTextField t,t1;     
    //Default display , displaying the screen.This should be the abstract method
      public void display()
        JLabel l=new JLabel("UserName");
        t=new JTextField(10);
        JLabel l1=new JLabel("Password");
        t1=new JPasswordField(10);
        t.setText("admin");
        t1.setText("admin");
        JButton b=new JButton("Login");
        b.addActionListener(this);
           panel.add(l);
           panel.add(t);
           panel.add(l1);
           panel.add(t1);
           panel.add(b);
           currentframe.getContentPane().add(panel);
           currentframe.setSize(400,400);
           currentframe.setVisible(true);      
      public static void main(String ar[]) throws Exception     
           ClientComp c1 = (ClientComp)(Class.forName(ar[0])).newInstance();
           c1.action();             
           System.out.println("Hello11");
      public void actionPerformed(ActionEvent e)
           //Do someprocessing if required
           if(t.getText().equals("admin")&&t1.getText().equals("admin"))
           callNextView(new Comp2());  
           else
            System.out.println("invalid login");     
    } Similarly you can develop the other components and you have to take care of the display() and the user action Event which eventually calls the callNextView.I hope there might be the cases where this has been implemented ..
    Regards
    Vicky

  • Best practice for client-server(Socket) application

    I want to build a client-server application
    1) On startup.. client creates connection to Server and keeps reading data from server
    2) Server keeps on sending different messages
    3) Based on messages(Async) from server client view has to be changed
    I tried different cases ended up facing IllegalStateChangeException while updating GUI
    So what is the best way to do this?
    Please give a working example .
    Thanks,
    Vijay
    Edited by: 844427 on Jan 12, 2012 12:15 AM
    Edited by: 844427 on Jan 12, 2012 12:16 AM

    Hi EJP,
    Thanks for the suggestion ,
    Here is sample code :
    public class Lobby implements LobbyModelsChangeListener{
        Stage stage;
        ListView<String> listView;
        ObservableList ol;
         public Lobby(Stage primaryStage) {
            stage = primaryStage;
               ProxyServer.startReadFromServer();//Connects to Socket Server
             ProxyServer.addLobbyModelChangeListener(this);//So that any data from server is fetched to Lobby
            init();
        private void init() {
              ProxyServer.getLobbyList();//Send
            ol = FXCollections.observableArrayList(
              "Loading Data..."
            ol.addListener(new ListChangeListener(){
                @Override
                public void onChanged(Change change) {
                    listView.setItems(ol);
         Group root = new Group();
        stage.setScene(new Scene(root));
         listView = new ListView<String>();
        listView.maxWidth(stage.getWidth());
         listView.setItems(ol);
         listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
        istView.setOnMouseClicked(new EventHandler<MouseEvent>(){
                @Override
                public void handle(MouseEvent t) {
    //                ListView lv = (ListView) t.getSource();
                    new NewPage(stage);
         root.getChildren().add(listView);
         @Override
        public void updateLobby(LobbyListModel[] changes) {
    //        listView.getItems().clear();
            String[] ar = new String[changes.length];
            for(int i=0;i<changes.length;i++)
                if(changes!=null)
    System.out.println(changes[i].getName());
    ar[i] = changes[i].getName();
    ol.addAll(ar);
    ProxyServer.javaProxyServer
    //Implements runnable
    public void run()
         ......//code to read data from server
    //make array of LobbyListModel[] ltm based on data from server
         fireLobbyModelChangeEvent(ltm);
    void addLobbyModelChangeListener(LobbyModelsChangeListener aThis) {
    this.lobbyModelsChangeListener = aThis;
         private void fireLobbyModelChangeEvent(LobbyListModel[] changes) {
    LobbyModelsChangeListener listner
    = (LobbyModelsChangeListener) lobbyModelsChangeListener;
    listner.updateLobby(changes);
    Exception :
    java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-5
             at line         ol.addAll(ar);
    But ListView is getting updated with new data...so not sure if its right way to proceed...
    Thanks,
    Vijay                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Pjc for client-server mode

    hi,
    i have been using pjc for customized text field and text area and have successfully implemented it on windows and sun solaris. we have used pjc for working in non english character set so that the user can directly type in the required character set without any supporting application to enable new keyboard mapping. but i have a serious problem.
    these customized components work only on the webforms mode.i.e. on browser or applet. they dont work in the normal client server mode. is it possible that i can have them running in the normal runtime also. if yes then how and if not what is the work around for achieving the same without much effort.
    awaiting a prompt reply.
    thanks in advance,
    regards,
    Yousuf.
    Delhi.

    Dear Yousof,
    I want to do the same thing that u'vve already acheived, I want to customize oracle forms texfields and instead of EXTENDING VTextfield I want to extend JTextfield and ofcourse implementing IView interface.
    But I get problems, would u mind be kind enough to instruct me in doing that?
    Best regrds,
    Sasan

  • Can i use forms 9i or 10g for client/server applications

    Right now, we are using oracle 9i DB and developer suite 10g. I have to build a client/server application. In one of the OTN articles, it says that from forms 9i onwards, it's not supporting client/server applications. Do i have to use 6i for this.
    Thank You.
    Sree.

    That's right. Only web deployment is support from 9i onwards. Bad decision since Oracle seems to ignore their customer's view

  • Can i use forms 9i for client server applicaitons

    Hi,
    I have to build a client/server application.Right now, we are using oracle 9i and developer suite 10g. In one of the articles on OTN, it says that from forms 9i onwards, it's not supporting client/server model. Do i have to use 6i for this.
    Thank you.
    Sree.

    The last Forms version that can be run in c/s mode is 6i.

  • Tips for Client-Server project please...

    I've written a few Java apps (some very simple, some not quite so simple) so far and I think I'm ready to begin tackling my big goal. I want to create a distributable client desktop application that will actually be very simple in functionality. I want the clients to be able to connect to a server (that I will also be creating) for authentication and then allow automated messages to be sent to other clients also connected to the network. I'd like any links to tutorials, libraries, and anything else that would help point me in the right direction. Thanks!

    Actually, if you're on about clients sending messages to each other, then you're not really talking about client-server apps at all. You're veering off into JMS territory, maybe even ESB territory(but probably not). Have a butchers at ActiveMQ, and Camel, both from Apache, for that.
    Either way, I wouldn't bother creating your own server, just use an existing one. Jetty's nice and lightweight, and easy to embed. You're about to say "I'd rather create my own" but it's a bothersome task that people far more skilled than you (and me, before you take offence) have already done much better than you ever will. Take advantage of that fact, and concentrate on the specifics of your own app.

  • MUDE for client-server configuration

    I can easily connect from a client remotely to a server hosting OBIEE, by creating a ODBC system DSN that points to
    the server, and choosing this DSN from the list of available DSN from Administration => file => open => online. works
    perfectly
    When I configure projects at OBIEE server as a Multiuser Development Environment, I can not connect from a client remotely to a server. Administration => file => nultiuser => checkout does not give me an option to choose the system DSN for remote server
    Can someone clarify steps to configure MUDE in a client-server environment
    Thanks

    Amrita,
    In the article by Venkat, that you referred to in your response , I read the article, I have a few questions
    1. When I install OBIEE, the Master Repository automatically created at the c:\OracleBi\server\Repository directory
    When you create projects, they are created in the Master Repository.
    Do I then copy the master repository to Shared Network directory, ex. N:\SharedRepository
    2. When i start the AdminTool from the client m/c, how will the client knows to connect the remote server
    I have not gotten to this part yet, just want to clarify, if any configuration necessary on the client side,
    before file => Multiuser => checkout
    Thanks

  • Need Help for client - server - client question [Sockets]

    Hi
    I have read the http://java.sun.com/docs/books/tutorial/networking/sockets/index.html tutorial and made this Knock Knock Application.
    But now, I want that one client can view all the other clients which are connected to the server, and interract with a selected cleint over the server (client - server - client).
    But I have no idea how to build such a registration concept?
    A concrete hint (or link) how to realise this would be very helpful. I searched all the internet for examples, but I dont found a simple example.
    Thanks in advance
    greeds

    wSam,
    It appears that Sun considers RMI to be simpler, although less efficient than the alternative:
    http://java.sun.com/developer/technicalArticles/ALT/sockets/
    This article also talks about object serialization, which I am a fan of. Suppose that you want to send a data structure containing lots of information (like all connected users). You can actually pass an object (rather than text) across the network using ObjectOutputStream and receive it on the other end with ObjectInputStream. You might create your own Command class for passing objects between the client and server instead of using RMI. The Command class might hold flags that indicate which method should take place on the remote machine (i.e. send chess move command).

  • Use of servlet http tunneling for client server communication

    Hello I am having a problem connecting a simple client applet to a server application. I can connect the two directly using sockets. However, when I try to connect the two via a servlet the input stream cannot be accessed. The application is purely for demonstration. Here is some of the source code
    A servlet for http tunneling
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class SocketServlet extends HttpServlet
         ServletInputStream servletinput;
         ServletOutputStream servletoutput;
         Socket socket;
         DataOutputStream dataoutput;
         DataInputStream datainput;     
         public SocketServlet()
    public void init(ServletConfig servletconfig) throws ServletException
    super.init(servletconfig);
    log("Socket servlet initialized.");
         public void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException
    try
    servletinput = request.getInputStream();
    socket = new Socket( InetAddress.getByName( "127.0.0.1" ), 5000 );
    dataoutput = new DataOutputStream( socket.getOutputStream() );
    try
                        byte[] inbytes = new byte[1024];
                        servletinput.read( inbytes );
                        String inmessage = new String( inbytes );                    
                        dataoutput.writeBytes( inmessage );
    catch(IOException ioex)
    dataoutput.flush();
    datainput = new DataInputStream( socket.getInputStream() );
    servletoutput = response.getOutputStream();
    try
    byte[] outbytes = new byte[1024];
    datainput.read( outbytes );
    servletoutput.write( outbytes );
    catch(IOException ioex)
    servletoutput.flush();
    servletoutput.close();
    catch(Exception ex)
    // Server.java
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Server extends JFrame {
    private JTextField enter;
    private JTextArea display;
    DataOutputStream output;
    DataInputStream input;
    public Server()
    super( "Server" );
    Container c = getContentPane();
         enter = new JTextField();
         enter.setEnabled( false );
         c.add( enter, BorderLayout.SOUTH );
    display = new JTextArea();
    c.add( new JScrollPane( display ),
    BorderLayout.CENTER );
    setSize( 300, 150 );
    show();
    public void runServer()
    ServerSocket server;
    Socket connection;
    int counter = 1;
    try {
    // Step 1: Create a ServerSocket.
    server = new ServerSocket( 5000, 100 );
    while ( true ) {
    // Step 2: Wait for a connection.
    display.setText( "Waiting for connection\n" );
    connection = server.accept();
    display.append( "Connection " + counter +
    " received from: " +
    connection.getInetAddress().getHostName() );
    // Step 3: Get input and output streams.
    output = new DataOutputStream(
    connection.getOutputStream() );
    input = new DataInputStream(
    connection.getInputStream() );
    display.append( "\nGot I/O streams\n" );
    // Step 4: Process connection.
    String message =
    "SERVER>>> Connection successful";
    output.writeBytes( message );
    enter.setEnabled( true );
                   display.append( "\nConnected\n" );
    do {
    try {
                        byte[] mess = new byte[1024];
    input.read( mess );
    display.append( "\n" + message );
    display.setCaretPosition(
    display.getText().length() );
                   catch (IOException ioex )
    } while ( !message.equals( "CLIENT>>> TERMINATE" ) );
    // Step 5: Close connection.
    display.append( "\nUser terminated connection" );
    enter.setEnabled( false );
    output.close();
    input.close();
    connection.close();
    ++counter;
    catch ( EOFException eof ) {
    System.out.println( "Client terminated connection" );
    catch ( IOException io ) {
    io.printStackTrace();
    private void sendData( String s )
    try {
    output.writeBytes( "SERVER>>> " + s );
    display.append( "\nSERVER>>>" + s );
    catch ( IOException cnfex ) {
    display.append(
    "\nError writing object" );
    public static void main( String args[] )
    Server app = new Server();
    app.addWindowListener(
    new WindowAdapter() {
    public void windowClosing( WindowEvent e )
    System.exit( 0 );
    app.runServer();
    // Fig. 21.4: Client.java
    // Set up a Client that will read information sent
    // from a Server and display the information.
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.util.zip.*;
    public class Client extends Applet implements ActionListener {
    private TextField enter;
    private TextArea display;
    DataOutputStream output;
    DataInputStream input;
    private Button button, button2;
    URLConnection connection;
    private byte[] bytes1, bytes2;
    private String message, message2;
    public void init()
    setLayout( new BorderLayout() );
    enter = new TextField( " Enter text here " );
    enter.setEnabled( false );
    enter.addActionListener( this );
    add( enter, BorderLayout.NORTH );
    display = new TextArea( 4, 30 );
         display.setEditable( false );
    add( display, BorderLayout.CENTER );
         button = new Button( "Connect" );
         button.addActionListener( this );
         add( button, BorderLayout.SOUTH );
    public void runClient()
    Socket client;
    try {
    // Step 1: Create a Socket to make connection.
    display.setText( "Attempting connection\n" );
              URL currentpage = getCodeBase();
              String protocol = currentpage.getProtocol();
              String host = currentpage.getHost();
              int port = 8100;
              String urlsuffix = "/servlet/SocketServlet";
              URL dataurl = new URL( "http://localhost:8100/servlet/SocketServlet" );
              connection = dataurl.openConnection();
    connection.setDoOutput(true);
    connection.setDoInput(true);
    connection.setRequestProperty("Content-type", "application/octet-stream");
              connection.setUseCaches( false );
              display.append( "\nConnected to: " + host );          
    // Step 2: Get the output streams.
    output = new DataOutputStream(
    connection.getOutputStream() );
              display.append( "\n got output stream\n" );
              // Step 3 get input connection
              try
              display.append( "\nAttempting to connect to input stream\n" );
                   input = new DataInputStream( connection.getInputStream() );
                   bytes1 = new byte[1024];
                   input.readFully( bytes1 );
                   display.append( "\nGot input stream\n" );
                   message = new String( bytes1 );
                   display.append( "\n" + message + "\n" );          
              catch ( IOException ioex )
              // Step 3: Process connection.
              enter.setEnabled( true );
              do {
              try {
    bytes2 = new byte[1024];
              input.readFully( bytes2 );
              message2 = new String( bytes2 );
              display.append( "\n" + message2 );
              display.setCaretPosition(
              display.getText().length() );
              catch ( IOException ioex ) {
              display.append(
              "\nUnknown object type received" );
              } while ( !message.equals( "SERVER>>> TERMINATE" ) );
    // Step 4: Close connection.
    display.append( "Closing connection.\n" );
    output.close();
    input.close();
         catch (MalformedURLException mfe )
    catch ( EOFException eof ) {
    System.out.println( "Server terminated connection" );
    catch ( IOException e ) {
    e.printStackTrace();
    private void sendData( String s )
    try {
    message = s;
    output.writeBytes( "CLIENT>>> " + s );
    display.append( "\nCLIENT>>>" + s );
    catch ( IOException cnfex ) {
    display.append(
    "\nError writing object" );
    public void actionPerformed( ActionEvent e )
         if ( e.getActionCommand() == "Connect" )
              runClient();
         else
              sendData( e.getActionCommand() );
    public static void main(String args[])
    Frame f = new Frame("Chat Client");
         Client c = new Client();
         c.init();
         f.add("Center", c);
         f.setSize(300, 150);
         f.show();
    the connection appears to fail at client step 3, any help is super, thanks
    Aidan

    Hi,
    In your client you are trying to open OutputStream even though you are not using it.
    So there are two solutions here.
    1. If you dont need OutputStream your code shoud look like this
    try {
    // Step 1: Create a Socket to make connection.
    display.setText( "Attempting connection\n" );
    URL currentpage = getCodeBase();
    String protocol = currentpage.getProtocol();
    String host = currentpage.getHost();
    int port = 8100;
    String urlsuffix = "/servlet/SocketServlet";
    URL dataurl = new URL( "http://localhost:8100/servlet/SocketServlet" );
    connection = dataurl.openConnection();
    //connection.setDoOutput(true);
    connection.setDoInput(true);
    connection.setRequestProperty("Content-type", "application/octet-stream");
    connection.setUseCaches( false );
    display.append( "\nConnected to: " + host );
    // Step 2: Get the output streams.
    //output = new DataOutputStream(
    //connection.getOutputStream() );
    //display.append( "\n got output stream\n" );
    display.append( "\n Not interested in output stream\n" );
    //Step 3 Inpustream related
    // Step 4: Close connection.
    display.append( "Closing connection.\n" );
    //output.close();
    input.close();
    1. If you need OutputStream, close your OutputStream before even trying to get InputStream, your code should like this
    try {
    // Step 1: Create a Socket to make connection.
    display.setText( "Attempting connection\n" );
    URL currentpage = getCodeBase();
    String protocol = currentpage.getProtocol();
    String host = currentpage.getHost();
    int port = 8100;
    String urlsuffix = "/servlet/SocketServlet";
    URL dataurl = new URL( "http://localhost:8100/servlet/SocketServlet" );
    connection = dataurl.openConnection();
    //connection.setDoOutput(true);
    connection.setDoInput(true);
    connection.setRequestProperty("Content-type", "application/octet-stream");
    connection.setUseCaches( false );
    display.append( "\nConnected to: " + host );
    // Step 2: Get the output streams.
    output = new DataOutputStream(
    connection.getOutputStream() );
    display.append( "\n got output stream\n" );
    //I'll do whateve I've to do with outputstream
    //done with output stream closing
    output.close();
    //Step 3 Inpustream related
    // Step 4: Close connection.
    display.append( "Closing connection.\n" );
    //output.close();
    input.close();
    hope this works
    all the best,
    Raj

Maybe you are looking for