Fetching a URL  from a socket output or input stream in a proxy server

We have written a proxy server in java .
It connects with a client on some local port and forwards the request of the client to main server through socket connections.
The code is as follows...
* BasicProxyServer.java
* A simple multithreaded proxy server.
* A client connects to theserver. The server starts a
* separate threads for data flow though two Sockets.
* The first socket communicates with the socket of the client.
* The second socket is used to communcate with the main server
* for which this server is a proxy. The sockets are connected by pipes.
import java.net.*;
import java.io.*;
public class BasicProxyServer {
     private static int serverPort;
     private static String primaryServerHost;
     private static int primaryServerPort;
     // 1st arg: port to listen on
     // 2nd arg: primary server IP
     // 3rd arg: primary server port
     public static void main(String [] args) {
          serverPort = Integer.parseInt(args[0]);
          primaryServerHost = args[1];
          primaryServerPort = Integer.parseInt(args[2]);
          BasicServer bserv = new BasicServer(serverPort,primaryServerHost,primaryServerPort);
class BasicServer extends Thread {
     private int serverPort;
     private String primaryHost;
     private int primaryPort;
     private ServerSocket servSock = null;
     public BasicServer(int port, String primSrv, int primPort) {
          serverPort = port;
          primaryHost = primSrv;
          primaryPort = primPort;
          start();
     public void run() {
          Socket clientSock = null;
          Socket primaryServerSock = null;
          try {
               servSock = new ServerSocket(serverPort);
          catch (IOException e) {
               e.printStackTrace();
          while(true) {
               try {
                    clientSock = servSock.accept();
                    primaryServerSock = new Socket(primaryHost, primaryPort);
                    PipedInputStream fromClient = new PipedInputStream();
                    PipedOutputStream toMainServer = new PipedOutputStream(fromClient);
                    PipedInputStream fromMainServer = new PipedInputStream();
                    PipedOutputStream toClient = new PipedOutputStream(fromMainServer);
                    Talk clientToMainServer = new Talk(clientSock, fromClient, primaryServerSock, toMainServer);
                    Talk mainServerToClient = new Talk(primaryServerSock, fromMainServer, clientSock, toClient);
                    clientToMainServer.start();
                    mainServerToClient.start();
               catch (IOException e) {
                    e.printStackTrace();
     // Override finalize() to close server socket
protected void finalize() {
if (servSock != null) {
try {
servSock.close();
} catch (IOException e) {
e.printStackTrace();
servSock = null;
class Talk extends Thread {
     private Socket incoming;
     private Socket outgoing;
     private InputStream in;
     private OutputStream out;
     private InputStream from;
     private OutputStream to;
     Talk(Socket inSock, InputStream in, Socket outSock, OutputStream out) {
          this.in = in;
          this.out = out;
          incoming = inSock;
          outgoing = outSock;
     public void run() {
          int aByte;
          try {
               from = incoming.getInputStream();
               to = outgoing.getOutputStream();          
               while(( aByte = from.read()) != -1 ) {     //read from socket
                    out.write(aByte);     // write to pipe`
                    // read the byte from the pipe
                    to.write(in.read());          // write it to the output socket stream
                    to.flush();
               to.close();
               from.close();
               if(incoming != null) {
                    incoming.close();
                    incoming = null;
               if(outgoing != null) {
                    outgoing.close();
                    outgoing = null;
          catch (SocketException e) {
          // there is one for a closed socket. Seems to have no effect.
          //     e.printStackTrace();
          catch (IOException e) {
               e.printStackTrace();
Here,when client gives any URL in the address bar in the web browser the request is forwarded to this proxy server.
We want to fetch the URL which client enters in order to implement content filtering and also store the most visited sites by each user .
But we don't know how to fetch the URL from the socket input or output stream.
Can you suggest any suitable solution for the same??

Shailesh24 wrote:
We want to fetch the URL which client enters in order to implement content filtering and also store the most visited sites by each user .
But we don't know how to fetch the URL from the socket input or output stream.
Can you suggest any suitable solution for the same??Yes. Write a proxy server that actually speaks HTTP.

Similar Messages

  • HTTP connection from OSB web service to external system via a Proxy Server

    Dear experts,
    May I know has anyone tried to use HTTP protocol to send a request from OSB web service to external system via a proxy server? Heard that we need to establish some sort of tunnel (socket) to talk to Proxy Server. Can you please any have sample code or configuration steps to share?
    Thank you very much!!

    http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/consolehelp/global_resources.html#wp1137294
    Adding Proxy Servers
    Use the Summary of Proxy Servers page to add and configure Proxy Server resources and make them available in Oracle Service Bus as a system resource. You must be in an active session to configure or reconfigure Proxy Server resources.
    1. If you have not already done so, click Create to create a new session or click Edit to enter an existing session. See Using the Change Center.
    2. Select System Administration > Proxy Servers.
    3. Click Add.
    4. In the Name field, enter a name for the Proxy Server resource. This is a required field.
    5. In the Description field, enter a short description for the Proxy Server resource.
    6. In the Host-Port Parameters section, enter the following information:
    1. In the Server Host field, enter the host name or IP address of the Proxy Server. This is a required field.
    The Server Host name for the Oracle Service Bus proxy server must be identical to the server host name of the actual proxy server.
    2. In the Clear Text Port field, enter the Proxy Server clear-text port number.
    3. In the SSL Port field, enter the Proxy Server SSL port number. You must enter either a clear text or SSL port number.
    4. Click Add.
    You can configure multiple Proxy Servers for each Proxy Server resource. This enables Oracle Service Bus to perform load balancing and offer fault tolerance features for the Proxy Server resource.
    7. If the Proxy Server performs proxy authentication, enter a user name in the User Name field, and the associated password in the Password and Confirm Password fields.
    These fields are optional, and required only if the Proxy Server is secured.
    8. Click Save to create and save the Proxy Server resource in the current session.
    9. To end the session and deploy the configuration to the run time, click Activate under Change Center.

  • Anytime i try and eprint from my ipad the printer says i need a proxy server and code?

    Bought new Photosmart 6510e all in one. Set up went well including wireless internet setup. When I try to use my ipad and send document to print the printer says I need a "Proxy server name and code" I don't know what this means or how to find this server?
    What can I do to get this going?The computer I have is an Acer with Windows Vista.   

    Hello Manny12,
    I would start but suggesting you power cycle the printer. You can do this by following these steps:
    While the printer is still on, unplug the power cord from the printer, leave it unplugged for 30 seconds, then reconnect the power cord to the printer. Once plugged back in the printer should power on automatically.
    You also may try restoring the network defaults and re-connecting your printer back to your wireless network. If you are still experiencing issues you may also want to disable and re-enable Web Services.
    If you have any further issues or questions you can reply to this post and I will try to assist you.
    If I have solved your issue, please feel free to provide kudos and make sure you mark this thread as solution provided!
    Although I work for HP, my posts and replies are my own opinion and not those of HP.

  • Regarding fetching the data from Tcode FBL3N output list.

    Hi experts,
    I want to get the data from the FBL3N Transaction output to into my program by giving Company code G/L account number and Fiscal year as input to FBL3N tcode.
    Please guide me how to approach it its urgent.

    Hi Naveen,
    SUBMIT stdreport  EXPORTING LIST TO MEMORY
                  AND RETURN.
    With the above statement you can export the list out put and
    by using the below function module in the your program,
    CALL FUNCTION 'LIST_FROM_MEMORY'
      TABLES
        listobject = list_tab
      EXCEPTIONS
        not_found  = 1
        OTHERS     = 2.
    IF sy-subrc = 0.
      CALL FUNCTION 'WRITE_LIST'
        TABLES
          listobject = list_tab.
    ENDIF.
    Regards,
    Madhu.

  • BufferedReader Input "echo" from Printwriter socket output

    Hi to everybody.
    I built a simple client - server socket-based application.
    When i use connect two java sockets everything works fine (i can chat normally).
    When i try to connect to a windows Hyperterminal (or command line Telnet) the communications
    establish correctly, but when i send (printwriter.write) a character (or a set of) from the Java i see it (them)
    coming back to socket's BufferedReader's next read() operation..
    How is it possible?
    Does it depend on hyperterminal/telnet implementations?
    Thanks in advance.

    Does it depend on hyperterminal/telnet implementations?They are doing simple echoing, aren't they?

  • Questions about reading/writing with output and input streams

    I'm getting a bit confused on this subject. I have written an array of doubles to a file, and now I need to know how to read them back in to another array. I have also wrapped each double into its own object, but I need to know how to write those to a file, and read the doubles contained in them back into an array.
    Here is what I have so far; the method that writes the array of doubles to a file.
    public void writePrimDoubles() {
              DataOutputStream outStream;
              System.out.println("Now writing the values to file...");
              try     {               
                   outStream = new DataOutputStream(new FileOutputStream("file.dat"));
              catch (IOException ex) {
                   System.out.println("Error opening file");
              return;
              try {
                   for(int i = 0; i<arraySize; i++)
                        outStream.writeBytes(numberArray[i] + "\n");
                   outStream.close();
              catch(IOException e) {
                   System.out.println("Error writing to file");
         }

    * writes all doubles in the given array to the file 'file.dat'
    public void writePrimDoubles(double[] array) throws IOException {
       DataOutputStream out = new DataOutputStream(new FileOutputStream("file.dat"));
       for(int i=0; i<array.length; i++) {
          out.writeDouble(array);
    out.close();
    * reads in all stored doubles from the given file ('file.dat').
    * cause of each double has been written to a 8byte part of the file
    * you could get the number of doubles stored in the file by dividing
    * its filesize by 8.
    * Alternatively you might first store all read doubles as Double in
    * a list (e.g. java.util.ArrayList). After reading all doubles you could then
    * create a new double[] with the lists size (double[] array = new double[list.size()];)
    * -> this alternative is commented out in the following code.
    public double[] readPrimDoubles() throws IOException {
    File file = new File("file.dat");
    DataInputStream in = new DataInputStream(new FileInputStream(file));
    double[] array = new double[file.length()/8];
    for(int i=0; i<array.length; i++) {
    array[i] = in.readDouble();
    in.close();
    return array;
    ArrayList list = new ArrayList();
    try {
    while(true) {
    list.add(new Double(in.readDouble()));
    catch(EOFException e) {} // catchs the exception thrown when end of file is reached
    in.close();
    double[] array = new double[list.size()];
    for(int i=0; i<list.size(); i++) {
    array[i] = ((Double)list.get(i)).doubleValue();
    return array;
    For further information on the classes you have to use you might have a look to the concerning API documentation (http://java.sun.com/j2se/1.4.2/docs/api/). In this docs you could find all methods, constructors and fields accessable for a class.
    have fun...

  • Applet using socket connection always go through proxy server

    Socket connection with socks always go through proxy server
    We have two applets in different codebases using socket to talk to each other, until now nothing new, but the problem is that we are behind a proxy server with socks and because of that, the connection always go through the proxy server even with proxy override point to the applet machine. We have tried a lof of things and until now nothing worked, it looks like the socket is ignoring proxy override configuration. We would like to know if there is a way to solve this problem making the applets comunicate to each other ignoring the proxy server. It should happen when we set the plug-in option to "no proxy host", but it doesn't. Maybe it can be a bug of JVM, I don't know, just maybe, and if it's true, any other good idea would be welcome as well.
    Thanks in advance.

    Hi,
    I am not very much sure if I can help you. In my previous experience, once you set the system property to use the proxy, then the jvm uses the proxy. If you want disable, in your code, you have to disable it.
    like System.setProperty("socksProxyHost","someHost"), Properties props = System.getProperties(); props.remove(("socksProxyHost");

  • How to fetch the data from databse table and get the required output

    Hi,
    I have made a project that connects CEP to database table but i m getting some problem in fetching the data from database.
    From the following code :
    If the where condition is removed then the application runs fine but i am still not able to fetch the data from the table because it is not showing any output.
    Can anyone please suggest me that how to write WHERE statement correctly and how i will be able to see the output.
    Following is the config.xml for processor:
    ======================================
    <?xml version="1.0" encoding="UTF-8"?>
    <wlevs:config xmlns:wlevs="http://www.bea.com/ns/wlevs/config/application"
         xmlns:jdbc="http://www.oracle.com/ns/ocep/config/jdbc">
         <processor>
              <name>JDBC_Processor</name>
              <rules>
                   <query id="q1"><![CDATA[
                             SELECT STOCK.SYMBOL as symbol, STOCK.EXCHANGE as exchange
                             FROM ExchangeStream [Now] as datastream, STOCK
                             WHERE datastream.SYMBOL = datastream.SYMBOL ]]></query>
              </rules>
         </processor>
         <jms-adapter>
              <name>JMS_IN_Adapter</name>
              <jndi-provider-url>t3://CHDSEZ135400D:7001</jndi-provider-url>
              <destination-jndi-name>jms.TestKanikaQueue</destination-jndi-name>
              <user>weblogic</user>
              <password>welcome1</password>
         </jms-adapter>
    </wlevs:config>
    Following is the assembly file:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi"
         xmlns:wlevs="http://www.bea.com/ns/wlevs/spring" xmlns:jdbc="http://www.oracle.com/ns/ocep/jdbc"
         xmlns:spatial="http://www.oracle.com/ns/ocep/spatial"
         xsi:schemaLocation="
              http://www.springframework.org/schema/beans
              http://www.springframework.org/schema/beans/spring-beans.xsd
              http://www.springframework.org/schema/osgi
              http://www.springframework.org/schema/osgi/spring-osgi.xsd
              http://www.bea.com/ns/wlevs/spring
              http://www.bea.com/ns/wlevs/spring/spring-wlevs-v11_1_1_3.xsd
              http://www.oracle.com/ns/ocep/jdbc
              http://www.oracle.com/ns/ocep/jdbc/ocep-jdbc.xsd
              http://www.oracle.com/ns/ocep/spatial
              http://www.oracle.com/ns/ocep/spatial/ocep-spatial.xsd">
         <wlevs:event-type-repository>
              <wlevs:event-type type-name="StockEvent">
                   <wlevs:properties>
                        <wlevs:property name="SYMBOL" type="byte[]" length="16" />
                        <wlevs:property name="EXCHANGE" type="byte[]" length="16" />
                   </wlevs:properties>
              </wlevs:event-type>
              <wlevs:event-type type-name="ExchangeEvent">
                   <wlevs:class>com.bea.wlevs.event.example.JDBC_CEP.ExchangeEvent</wlevs:class>
              </wlevs:event-type>
              <wlevs:event-type type-name="StockExchangeEvent">
                   <wlevs:properties>
                        <wlevs:property name="symbol" type="byte[]" length="16" />
                        <wlevs:property name="price" type="byte[]" length="16" />
                        <wlevs:property name="exchange" type="byte[]" length="16" />
                   </wlevs:properties>
              </wlevs:event-type>
         </wlevs:event-type-repository>
         <bean id="readConverter" class="com.bea.wlevs.adapter.example.JDBC_CEP.Adapter_JDBC" />
         <bean id="outputJDBCBean" class="com.bea.wlevs.bean.example.JDBC_CEP.OutputBean_JDBC">
         </bean>
         <wlevs:adapter id="JMS_IN_Adapter" provider="jms-inbound">
              <wlevs:listener ref="ExchangeStream" />
              <wlevs:instance-property name="converterBean"
                   ref="readConverter" />
         </wlevs:adapter>
         <wlevs:processor id="JDBC_Processor" advertise="true">
              <wlevs:listener ref="OutputChannel" />
              <wlevs:table-source ref="STOCK" />
         </wlevs:processor>
         <wlevs:channel id="ExchangeStream" event-type="ExchangeEvent" advertise="true">
              <wlevs:listener ref="JDBC_Processor" />
         </wlevs:channel>
         <wlevs:channel id="OutputChannel" event-type="StockExchangeEvent"
              advertise="true">
              <wlevs:listener ref="outputJDBCBean" />
         </wlevs:channel>
         <wlevs:table id="STOCK" event-type="StockEvent"
              data-source="StockDs" table-name="STOCK" />
         <wlevs:table id="STOCK_EXCHANGE" event-type="StockExchangeEvent"
              data-source="StockDs" table-name="STOCK_EXCHANGE" />
    </beans>
    ExchangeEvent.java:
    package com.bea.wlevs.event.example.JDBC_CEP;
    public class ExchangeEvent {
         public String SYMBOL;
         public String symbol;
         public String exchange;
         public ExchangeEvent() {
         public String getSYMBOL() {
              return SYMBOL;
         public void setSYMBOL(String sYMBOL) {
              SYMBOL = sYMBOL;
         public String getSymbol() {
              return symbol;
         public void setSymbol(String symbol) {
              this.symbol = symbol;
         public String getExchange() {
              return exchange;
         public void setExchange(String price) {
              this.exchange = price;
    Adapter Class:
    package com.bea.wlevs.adapter.example.JDBC_CEP;
    import com.bea.wlevs.adapter.example.JDBC_CEP.MyLogger;
    import com.bea.wlevs.adapters.jms.api.InboundMessageConverter;
    import java.text.DateFormat;
    import java.util.Date;
    import com.bea.wlevs.adapters.jms.api.MessageConverterException;
    import com.bea.wlevs.event.example.JDBC_CEP.ExchangeEvent;
    import javax.jms.JMSException;
    import javax.jms.Message;
    import javax.jms.TextMessage;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Random;
         public class Adapter_JDBC implements InboundMessageConverter{
         @SuppressWarnings("unchecked")
         public List convert(Message message) throws MessageConverterException, JMSException {
              Random rand = new Random();
              int unique_id = rand.nextInt();
              DateFormat dateFormat;
              dateFormat = DateFormat.getTimeInstance();
              dateFormat.format(new Date());
              MyLogger.info(unique_id + " CEP Start Time is: " + dateFormat.format(new Date()));
              System.out.println("Message from the Queue is :"+ message);
              TextMessage textMessage = (TextMessage) message;
              String stringMessage = textMessage.getText().toString();
              System.out.println("Message after getting converted into String is :"+ stringMessage);
                   String[] results = stringMessage.split(",\\s*"); // split on commas
                   ExchangeEvent event1 = new ExchangeEvent();
                   event1.setSYMBOL(results[0]);
         List events = new ArrayList(2);
         events.add(event1);
         return events;
    Output Bean Class :
    package com.bea.wlevs.bean.example.JDBC_CEP;
    import com.bea.wlevs.ede.api.StreamSink;
    import com.bea.wlevs.event.example.JDBC_CEP.ExchangeEvent;
    import com.bea.core.datasource.DataSourceService;
    public class OutputBean_JDBC implements StreamSink{
         public void onInsertEvent(Object event) {
         if (event instanceof ExchangeEvent) {
              ExchangeEvent cacheEvent = (ExchangeEvent) event;
         System.out.println("Symbol is: " + cacheEvent.getSymbol());
         System.out.println("Exchange is: " + cacheEvent.getExchange());
         System.out.println(DataSourceService.class.getClass());
    Kindly let me know if you need further info.

    Do you have StockDs configured in your server config.xml?
    I think the query should look more like this:
    SELECT stocks.SYMBOL, stocks.EXCHANGE
    FROM STOCK as stocks, ExchangeStream [Now] as datastream WHERE stocks.SYMBOL = datastream.SYMBOL
    Thanks
    andy

  • Trying to read from a socket character by character

    Hi all,
    I have a problem with reading from a socket character by character. In the code shown below I try and read each character, and then write it to a file. The information sent to a socket sent from a file, and EOF is marked with character of ascii code 28 (file separator). However using BufferedReader.read() I get -1 forever. Is it reading only the last character to have been sent to the socket?
    As a side note, if I use readLine() (making sure the socket is sent a newline at end of msg) I can get the message fine. However, I want to be able to receive a message with 0 or many newlines in it (basically contents of a text file), so I want to avoid the readLine() method.
    Any help at all is appreciated,
    Colm
    CODE SNIPPET:
    try
    serverSocket = new ServerSocket(listenToPort);
    System.out.println("Server waiting for client on port " + serverSocket.getLocalPort());
    while(true)
    inSocket = serverSocket.accept();
    System.out.println("New connection accepted " + inSocket.getInetAddress() + ":" + inSocket.getPort());
    input = new BufferedReader(new InputStreamReader(inSocket.getInputStream()));
    fileOutput = new BufferedWriter(new FileWriter(outputFilename));
    System.out.println("Ready to write to file: " + outputFilename);
    //receive each character and output it to file until file separator arrives
    while(!eof)
    inCharBuf = input.read();
    System.out.print(inCharBuf);
    //check for file separator (ASCII code 28)
    if (inCharBuf == 28) eof = true;
    //inChar = (char) inCharBuf;
    fileOutput.write(inCharBuf);
    System.out.println("Finished writing to file: " + outputFilename);
    inSocket.close();
    catch (IOException e)
    System.out.println("IO Error with serverSocket: " + e);
    System.exit(-1);
    }(tabbing removed as it was messing up formatting)

    My guess is that the code that is writing to the
    socket did not flush it. You said in one case you
    could read it (via readln) if the writer was writing
    lines (writeln flushes, I believe). Are you writing
    the exact same data to the socket in both tests?woo hoo, I hadn't flushed the buffers alright!
    for anyone with similar problems, I was missing this from my write-to-socket method:
    output.flush();
    where output was the BufferedWriter I had created to write to the socket.
    Thanks a lot for pointing it out!
    Colm

  • Error in fetching the data from textfield and inserting to the database..

    I'm using Java Swing as front end and MySQL as backend using the netbeans ide..I am trying to fetch the data from the textfiled in the form and insert to the database table.i've skipped the generated code..In the following code i get the erro cannot find symbol "stmt" in the actionPerformed method..
    mport java.awt.event.*;
    import java.sql.*;
    public class BarcodeReader extends JFrame implements ActionListener {
    public BarcodeReader() {
    initComponents();
    nb.addActionListener(this);
    public void jdbcConnect(){
    Connection con=null;
    String url = "jdbc:mysql://localhost:3306/";
    String db = "mynewdatabase";
    String driver = "com.mysql.jdbc.Driver";
    String user = "usrname";
    String pass = "pwd";
    try{
    String s=newtxt.getText();
    con=DriverManager.getConnection(url + db, user, pass);
    Statement stmt=con.createStatement();
    Class.forName(driver);
    public void actionPerformed(ActionEvent e){
    try{
    jdbcConnect();
    stmt.executeUpdate("INSERT into machine(mname) values '"+jTextField1.getText()+"'");
    }}catch (Exception ex) {
    System.out.println(ex);
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new BarcodeReader().setVisible(true);
    }

    There are far too many errors to try and clear.
    For one, the exception references the actionPerformed method (according to your text), so why is that not shown here?
    For another you are performing, possible time-consuming, actions, and even worse IO actions, on the event thread, which is a huge no-no.
    You are not closeing your resources properly, if at all, which is another huge no-no.
    You are completely mixing your "view" (the gui), and your "model" (the data related classes), which is another huge no-no.
    etc, etc, etc.

  • Help needed in accessing the url from which a swf file has been loaded

    Hi All,
    Can anyone help me out in finding the url of the swf file
    from which it has been loaded? The purpose of the url is, I am
    loading some flv files using relative path. I just want to achieve
    the same by appending the relative path to the parent swf url from
    where the parent was loaded.
    I am a newbie to AS3, So please don t mind if this is a silly
    question.
    Can anyone help me on this.
    Thanks in advance,
    Prabakaran Srinivasan.

    Hi,
    Thanks for the reply. I think the option you gave is only
    applicable when the AS3 class comes in the DisplayObject hierarchy.
    I want this information in an AS3 class which does not extend any
    of the Sprite or its super class hierarchy. Can you let me know the
    possibility of fetching the value from such a class which i
    specified???
    Thanks,
    Prabakaran Srinivasan.

  • Get URL from DMS in SAP

    Hi everybody,
    I have written an ABAP function in SAP where I export a URL of a document in SAP.
    All the images are stored in the DMS server and I fetch the url of the images by the function 'CVAPI_DOC_VIEW'
    When I execute this in SAP everythings works!
    When I execute this in Java webdynpro, the abap program don't find any link?
    Is there something wrong in my code because all parameters are the same.
    Regards

    Karsten,
      Thanks for the reply noted I will recopy this in EP
    Second I tried to get the KM piece to work for a couple of weeks even put in a help note and could not get the folders or any documents to come through any of the KM Browser's on the portal. I created varients etc etc.  So getting frustrated I decided to write my own.  Also because I wanted an iview that would pop all documents based on a picked equipment or material and from the three iviews I saw from KM they didn't seem to do that.  If you know of some documentation that you recommend please let me know
    Thanks Karsten
    Cheers,
    Devlin

  • Having issues finding out how many bytes are sent/recieved from a socket.

    Hello everyone.
    I've searched the forums and also google and it seems I can't find a way to figure out how many bytes are sent from a socket and then how many bytes are read in from a socket.
    My server program accepts a string (an event) and I parse that string up, gathering the relevant information and I need to send it to another server for more processing.
    Inside my server program after receiving the data ( a string) I then open another port and send it off to the other server. But I would like to know how many bytes I send from my server to the other server via the client socket.
    So at the end of the connection I can compare the lengths to make sure, I sent as many bytes as the server on the other end received.
    Here's my run() function in my server program (my server is multi threaded, so on each new client connection it spawns a new thread and does the following):
    NOTE: this line is where it sends the string to the other server:
    //sending the string version of the message object to the
                        //output server
                        out.println(msg.toString());
    //SERVER
    public class MultiThreadServer implements Runnable {
         Socket csocket;
         MultiThreadServer(Socket csocket) {
              this.csocket = csocket;
         public void run() {
              //setting up sockets
              Socket outputServ = null;
              //create a message database to store events
              MessageDB testDB = new MessageDB();
              try {
                   //setting up channel to recieve events from the omnibus server
                   BufferedReader in = new BufferedReader(new InputStreamReader(
                             csocket.getInputStream()));
                   //This socket will be used to send events to the z/OS reciever
                   //we will need a new socket each time because this is a multi-threaded
                   //server thus, the  z/OS reciever (outputServ) will need to be
                   //multi threaded to handle all the output.
                   outputServ = new Socket("localhost", 1234);
                   //Setting up channel to send data to outputserv
                   PrintWriter out = new PrintWriter(new OutputStreamWriter(outputServ
                             .getOutputStream()));
                   String input;
                   //accepting events from omnibus server and storing them
                   //in a string for later processing.
                   while ((input = in.readLine()) != null) {
                        //accepting and printing out events from omnibus server
                        //also printing out connected client information
                        System.out.println("Event from: "
                                  + csocket.getInetAddress().getHostName() + "-> "
                                  + input + "\n");
                        System.out.println("Waiting for data...");
                        //---------putting string into a message object-------------///
                        // creating a scanner to parse
                        Scanner scanner = new Scanner(input);
                        Scanner scannerPop = new Scanner(input);
                        //Creating a new message to hold information
                        Message msg = new Message();                    
                        //place Scanner object here:
                        MessageParser.printTokens(scanner);
                        MessageParser.populateMessage(scannerPop, msg, input);
                        //calculating the length of the message once its populated with data
                        int length = msg.toString().length();
                        msg.SizeOfPacket = length;
                        //Printing test message
                        System.out.println("-------PRINTING MESSAGE BEFORE INSERT IN DB------\n");
                        System.out.println(msg.toString());
                        System.out.println("----------END PRINT----------\n");
                        //adding message to database
                        testDB.add(msg);
                        System.out.println("-------Accessing data from Map----\n");
                        testDB.print();
                        //---------------End of putting string into a message object----//
                        //sending the string version of the message object to the
                        //output server
                        out.println(msg.toString());
                        System.out.println("Waiting for data...");
                        out.flush();
                   //cleaning up
                   System.out.println("Connection closed by client.");
                   in.close();
                   out.close();
                   outputServ.close();
                   csocket.close();
              catch (SocketException e) {
                   System.err.println("Socket error: " + e);
              catch (UnknownHostException e) {
                   System.out.println("Unknown host: " + e);
              } catch (IOException e) {
                   System.out.println("IOException: " + e);
    }Heres the other server that is accepting the string:
    public class MultiThreadServer implements Runnable {
         Socket csocket;
         MultiThreadServer(Socket csocket) {
              this.csocket = csocket;
         public void run() {
              try {
                   //setting up channel to recieve events from the parser server
                   BufferedReader in = new BufferedReader(new InputStreamReader(
                             csocket.getInputStream()));
                   String input;
                   while ((input = in.readLine()) != null) {
                        //accepting and printing out events from omnibus server
                        //also printing out connected client information
                        System.out.println("Event from: "
                                  + csocket.getInetAddress().getHostName() + "-> "
                                  + input + "\n");
    System.out.println("Lenght of the string was: " + input.length());
                        System.out.println("Waiting for data...");
                   //cleaning up
                   System.out.println("Connection closed by client.");
                   in.close();
                   csocket.close();
              } catch (IOException e) {
                   System.out.println(e);
                   e.printStackTrace();
    }Here's an example of the program works right now:
    Someone sends me a string such as this:
    Enter port to run server on:
    5656
    Listening on : ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=5656]
    Waiting for client connection...
    Socket[addr=/127.0.0.1,port=4919,localport=5656] connected.
    hostname: localhost
    Ip address: 127.0.0.1:5656
    Waiting for data...
    Event from: localhost-> UPDATE: "@busch2.raleigh.ibm.com->NmosPingFail1",424,"9.27.132.139","","Omnibus","Precision Monitor Probe","Precision Monitor","@busch2.raleigh.ibm.com->NmosPingFail",5,"Ping fail for 9.27.132.139: ICMP reply timed out",07/05/07 12:29:12,07/03/07 18:02:31,07/05/07 12:29:09,07/05/07 12:29:09,0,1,194,8000,0,"",65534,0,0,0,"NmosPingFail",0,0,0,"","",0,0,"",0,"0",120,1,"9.27.132.139","","","","dyn9027132107.raleigh.ibm.com","","","",0,0,"","","NCOMS",424,""
    Now my program makes it all nice and filters out the junk and resends the new string to the other server running here:
    Enter port to run server on:
    1234
    Listening on : ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=1234]
    Waiting for client connection...
    Socket[addr=/127.0.0.1,port=4920,localport=1234] connected.
    Parser client connected.
    hostname: localhost
    Ip address: 127.0.0.1:1234
    Event from: localhost-> PacketType: UPDATE , SizeOfPacket: 577 , PacketID: 1, Identifer: UPDATE: "@busch2.raleigh.ibm.com->NmosPingFail1" , Serial: 424 , Node: "9.27.132.139" , NodeAlias: "" , Manager: "Omnibus" , Agent: "Precision Monitor Probe" , AlertGroup: "Precision Monitor" , AlertKey: "@busch2.raleigh.ibm.com->NmosPingFail" , Severity: 5 , Summary: "Ping fail for 9.27.132.139: ICMP reply timed out",StateChange: 07/05/07 12:29:12 , FirstOccurance: 07/03/07 18:02:31 , LastOccurance: 07/05/07 12:29:09 , InternalLast: 07/05/07 12:29:09 , EventId: "NmosPingFail" , LocalNodeAlias: "9.27.132.139"
    Lenght of the string was: 579
    The length of the final string I sent is 577 by using the string.length() function, but when I re-read the length after the send 2 more bytes got added, and now the length is 579.
    I tested it for several cases and in all cases its adding 2 extra bytes.
    Anyways, I think this is a bad solution to my problem but is the only one I could think of.
    Any help would be great!

    (a) You are counting characters, not bytes, and you aren't counting the line terminators that are appended by println() and removed by readLine().
    (b) You don't need to do any of this. TCP doesn't lose data. If the receiver manages get as far as reading the line terminator when reading a line, the line will be complete. Otherwise it will get an exception.
    (c) You are assuming that the original input and the result of message.toString() after constructing a Message from 'input' are the same but there is no evidence to this effect in the code you've posted. Clearly this assumption is what is at fault.
    (d) If you really want to count bytes, write yourself a FilterInputStream and a FilterOutputStream and wrap them around the socket streams before decorating them with the readers you are using. Have these classes count the bytes going past.
    (e) Don't use PrintWriter or PrintStream on socket streams unless you like exceptions being ignored. Judging by your desire to count characters, you shouldn't like this at all. Use BufferedWriter's methods to write strings and line terminators.

  • Reading from a socket that requires an EOF.

    I'm trying to send a request and get a response from a socket.
    The server only seems to send the response once it gets an EOF. The only way I can seem to get an EOF is to close my output stream. However, when I close my output stream before reading from the input stream I get a "java.net.SocketException: Socket closed" exception.
    Is there a way to send an EOF signal in the output stream? Am I doing something wrong?
            Socket sock = new Socket(this.getHost(), this.getPort());
            DataOutputStream os = new DataOutputStream(sock.getOutputStream());       
            DataInputStream is = new DataInputStream(sock.getInputStream());
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            String responseString = new String();
            if (sock != null && os != null && is != null) {
                os.writeBytes(request);
                String responseLine;
                while ((responseLine = reader.readLine()) != null) {
                    responseString += responseLine;
            } //endif
            os.close();
            is.close();
            sock.close();

    Thanks for the reply. Is there no way around that? I don't have direct control over the server.
    I don't understand why I can't close the socket's input stream and still read from its output stream.
    Edited by: philgmo on Feb 18, 2008 3:20 PM

  • Fetching international characters from Clob

    Hi,
    I am trying to fetch hungarian characters from Clob data. I tried reading the Character Stream returned by Clob.getCharacterStream() in linux and it returns junk characters for those but the same works well with windows. I guess its picking up the platform depended default charset. Is there any way i can get the characters without changing the default charset of the OS ? any other way would be highly appreciated!
    Thanks in advance.

    Hi,
    I am trying to fetch hungarian characters from Clob
    data. I tried reading the Character Stream returned
    by Clob.getCharacterStream() in linux and it returns
    junk characters for those but the same works well
    with windows. Are you printing it to the console window on the OS to determine this?
    Then you are doing it incorrectly. That process of outputing a string requires mapping characters to the console character set.
    The only correct way to do this is to print the numeric representation of each character and see if that is correct. If it is correct then it is not a JDBC/driver problem. If it is not correct then it is a JDBC/driver problem.

Maybe you are looking for

  • HP pavilion dv6 restoratio​n incomplete after recovery

    I recently try to facotry reset my Hp pavilion dv6 using the recovery usb I make with the HP program when I brought this laptop, but it said "restoration incomplete".  I have ran the hard drive check and mem test at the BIOS and there isnt any proble

  • Adobe Acrobat - Create PDF 11.0.7 plugin | extension is not working at all in Google Chrome

    - I enable it on chrome://plugins/ Adobe Create PDF - Version: 11.0.07.47 Adobe Create PDF plug-in for Chrome - I enable it on chrome://extensions/ Adobe Acrobat - Create PDF 11.0.7.52 The icon is still on/light in the bar but when I click on it and

  • Basic PC requirements for Premiere Pro, After Effects editing DSLR video?

    I shoot primarily stills with Canon DSLR but have a number of (short) video projects... my current computer is not up to speed to handle much video editing etc. I'm in the market for a desktop and wonder what would be a good "basic" build or confirgu

  • OS 10.3.9

    Will the new iPod classic work work with OS 10.3.9? I know that the official requirements say you need tiger. iTunes 7.4 seems to run just fine on my computer. According to the iTunes 7.4 page these are the system requirements: Macintosh Requirements

  • Tools for converting from Designer 1.x to 6?

    I am about to work for a client that would like to convert their data model from Oracle Designer version 1.3 to version 6. They, of course, have both logical and physical models defined in the tool. They do not use Designer to create triggers or stor