Q: TCP Connections from an Applet

Hi,
is it possible to build a tcp socket connection on a specified port on the webserver with an unsigned applet?
as example: the applet is stored on the webserver, port 80.
somebody calls the applet with a webbrowser, and another connection, maybe port 7777, is build back to the webserver?
I just have to know if it is possible.
thanks for information

Yes

Similar Messages

  • How do i make http connection  from an applet to  a servlet

    i am not able to make a http connection from the applet to servlet
    my code for servlet is as follows
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class newDatabaseServlet extends HttpServlet {
    //      Connection con;
    // Statement stmt;
         public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
              resp.setContentType("text/content");
              System.out.println("megha");
              String mthd[] = req.getParameterValues("event");
              System.out.println(mthd.length);
              System.out.println(mthd);
              System.out.println(req.getQueryString());
              // System.out.println("megha");
    PrintWriter fw = new PrintWriter(new FileOutputStream(new File("e:/JRun/servers/default/default-app/mycontent.txt")));
    String s = "this text comes from servlet";
    fw.print(s);
    fw.flush();
              if(mthd[0].equalsIgnoreCase("callEditor")) {
                   openEditor(req,resp);
    public void openEditor(HttpServletRequest req, HttpServletResponse resp) {
         /* try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
         con = DriverManager.getConnection("jdbc:oracle:thin:@pc6:1521:oradba","test","test");
         catch(Exception e) {
              e.printStackTrace();
              try {
                   resp.sendRedirect("/RunApp1.html");
              catch(IOException e) {
                   e.printStackTrace();
    /*try {
         Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("jdbc:oracle:thin:@pc6:1521:oradba","test","test");
         catch(Exception e) {
         e.printStackTrace();
         resp.setContentType("text/html");
         PrintWriter output = resp.getWriter();
         try {
    stmt = con.createStatement();
    String strContent = "select * from edTable where newsid = 2";
    ResultSet rs = stmt.executeQuery(strContent);
    if(rs.next()) {
                   String newsText = rs.getString(2);
    /* StringBuffer buf = new StringBuffer();
                   buf.append("<B>servlet</B>");
                   try {
                   resp.sendRedirect("RunApp");
              catch(IOException e) {
                   e.printStackTrace();
    //               output.println(buf.toString());
    //          output.close();
    my code for applet is
    import javax.swing.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    import java.awt.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    public class EdApplet extends JApplet {
    public void init() {
         Container c;
         c = getContentPane();
    JPanel but = new JPanel();
    c.add(but,BorderLayout.NORTH);
    final JEditorPane je = new JEditorPane();
    JScrollPane jsp = new JScrollPane(je);
    HTMLEditorKit ht = new HTMLEditorKit();
    je.setEditorKit(ht);
    je.setEditable(true);
    HTMLDocument mdoc = (HTMLDocument)ht.createDefaultDocument();
    StyleSheet mcontext =mdoc.getStyleSheet();
    je.setDocument(mdoc);
    c.add(jsp,BorderLayout.CENTER);
    JPanel bot = new JPanel();
    c.add(bot,BorderLayout.SOUTH);
    JButton save = new JButton("save");
    but.add(save);
    String str = getInitialText();
         je.setText(str);
         String servletUrl="http://pc7:8100/servlet/newDatabaseServlet";
    try{
                   URL servletURL = new URL(servletUrl);
                   URLConnection servletConnection = servletURL.openConnection();
              servletConnection.setRequestProperty("event","saveText");
              servletConnection.setDoOutput(true);
              servletConnection.setUseCaches(false);
         catch(Exception e) {
    //          je.setText(e.printStackTrace());
         ActionListener lst = new ActionListener() {
              public void actionPerformed(ActionEvent ae) {
                   String save = je.getText();
                   saveText(save,je);
         save.addActionListener(lst);
    //je.setText("<B>this</B>");
    //URLConnection servletConnection = null;
    /* try {
              String servletUrl="http://pc7:8100/servlet/newDatabaseServlet";
              URL myUrl = new URL(servletUrl);
              servletConnection = myUrl.openConnection();
              servletConnection.setDoOutput(true);
              servletConnection.setUseCaches(false);
         /*     BufferedReader br = new BufferedReader(new InputStreamReader(servletConnection.getInputStream()));
    String t = br.readLine();
    je.setText(t);
         catch(Exception e) {
              e.printStackTrace();
    /* ActionListener lst = new ActionListener() {
              public void actionPerformed(ActionEvent ae) {
                   BufferedReader br = new BufferedReader(new InputStreamReader(servletConnection.getInputStream()));
                   String t = br.readLine();
    je.setText(t);
    click.addActionListener(lst);
    /*void String changeText(UrlConnection con) {
    BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream));
    String t = br.readLine();
    return t;
    public String getInitialText()
         //String me = null;
         URLConnection textConnection = null;
         StringBuffer sb = new StringBuffer();
         try {
                   String textUrl="http://pc7:8100/mycontent.txt";
                   URL myUrl = new URL(textUrl);
                   textConnection = myUrl.openConnection();
                   textConnection.setDoInput(true);
                   textConnection.setUseCaches(false);
                   BufferedReader br = new BufferedReader(new InputStreamReader(textConnection.getInputStream()));
                   // me = (String)servletConnection.getContent();
                   String s = null;
                   while((s = br.readLine())!=null) {
                        sb.append(s);
              catch(Exception e) {
                             e.printStackTrace();
                   return sb.toString();
         public void saveText(String saveStr,JEditorPane je) {
              //String saveStr = je.getText();
              //String servletUrl="http://pc7:8100/servlet/newDatabaseServlet?event='saveText'&newsid='2'";
              //String servletGet="http://pc7:8100/servlet/newDatabaseServlet";
              String servletUrl="http://pc7:8100/servlet/newDatabaseServlet";
              //String servletUrl = servletGet + "?"
              //     + URLEncoder.encode("event") + "="
         // + URLEncoder.encode("saveText");
    //     je.setText(servletUrl);
              try {
              URL servletURL = new URL(servletUrl);
              URLConnection servletConnection = servletURL.openConnection();
         //     servletConnection.setRequestProperty("event","saveText");
         servletConnection.setRequestProperty(
         "User-Agent","Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
              //System.out.println("from applet");
              servletConnection.setDoOutput(true);
              servletConnection.setUseCaches(false);
              //Propertiew prop = new Properties();
         //     prop.put("event","saveText");
              PrintStream out = new PrintStream(servletConnection.getOutputStream());
    out.println("event");
    out.close();
         catch(IOException e) {
              je.setText(e.toString());
    kindly tell me what is the error
    what is the best method of doing this
    thanking u in anticipation
    megha sood

    omg O_o
    We cannot debug your code, but:
    Did you try the servlet directly from your browser? Does it work?
    Best regards from Germany,
    r.v.

  • Outgoing TCP connections from VM have very low firewall state idle timeout -- how do you adjust?

    When I create a TCP connection from a VM to the internet, if I'm idle for more than a few minutes (say a SSH session), the TCP flow is torn down by some AZURE networking element in between.
    Incoming connections from the internet in don't seem to be affected.
    I assume this is an Azure firewall timeout somewhere.
    Is there any way to raise this?

    Hi,
    Thanks for posting here.
    Here are some suggestions:
    [1] - You can make sure the TCP connection is not idle. To keep your TCP connection active you can keeping sending some data before 60 seconds passes. This could be done via chunked transfer encoding; send something or you can just send blank lines to keep
    the connection active.
    [2] - If you are using WCF based application please have a look at below link:
    Reference:
    http://code.msdn.microsoft.com/WCF-Azure-NetTCP-Keep-Alive-09f50fd9
    [3] - If you are using TCP Sockets then you can also try ServicePointManager.SetTcpKeepAlive(true, 30000, 30000) might be used to do this. TCP Keep-Alive packets will keep the connection from your client to the load balancer open during a long-running HTTP
    request. For example if you’re using .NET WebRequest objects in your client you would set ServicePointManager.SetTcpKeepAlive(…) appropriately.
    Reference -
    http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.settcpkeepalive.aspx
    Hope this helps you.
    Girish Prajwal

  • Initiating a Socket Connection from the Applet in the html

    Hi
    i have a applet code as follows that listens for multicast messages. ...
    this works fine when i start it in the applet viewer (multicating server is in the same system)
    when i access the same through the html pages /// it gives an exception java.security.exception.Accessdenied ..................
    any idea to solve this is most appriciated ......
    Regards
    Venkat
    public class MyApplet extends Applet implements Runnable  {
         private static String group = "224.5.6.7"; 
         private static int port = 5000;
         private static MulticastSocket s;
         private static DatagramPacket pack;
         private static String msg = "Applet Started";
         public MyApplet() {
              super();
         public void destroy() {
         public String getAppletInfo() {
              return "This is my default applet created by Eclipse";
         public void init() {
              try{
              s = new MulticastSocket(port);
              catch(Exception e)
         public void start() {
                        try {
                             s.joinGroup(InetAddress.getByName(group));
                             Thread t  = new Thread((Runnable) this);
                             t.start();
                        } catch (UnknownHostException e) {
                             e.printStackTrace();
                        } catch (IOException e) {
                             e.printStackTrace();
         public void stop() {
         public void run()
              try{
                   byte buf[] = new byte[1024];
                   pack = new DatagramPacket(buf, buf.length);
                   while(true){
                   Thread.sleep(100);
                   s.receive(pack);
                   msg = ("Received data from: " + pack.getAddress().toString() +
                                                ":" + pack.getPort() + " with length: " + pack.getLength());
                   msg = msg +  new String(pack.getData(),0,pack.getLength());
                   repaint();
              catch(Exception e)
                   System.out.println(e.toString() + "from run");
         public void paint(Graphics g) {
             g.drawString(msg,0,10);
    [/code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I agree, when you run it in the applet viewer you use a special policy.
    http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
    second post and last post for the java class file
    If that didn't solve your problem than a full trace would be nice:
    To turn the full trace on (windows) you can start the java console, to be found here:
    C:\Program Files\Java\j2re1.4...\bin\jpicpl32.exe
    In the advanced tab you can fill in something for runtime parameters fill in this:
    -Djavaplugin.trace=true -Djavaplugin.trace.option=basic|net|security|ext|liveconnect
    if you cannot start the java console check here:
    C:\Documents and Settings\userName\Application Data\Sun\Java\Deployment\deployment.properties
    I think for linux this is somewhere in youruserdir/java (hidden directory)
    add or change the following line:
    javaplugin.jre.params=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    for 1.5:
    deployment.javapi.jre.1.5.0.args=-Djavaplugin.trace\=true -Djavaplugin.trace.option\=basic|net|security|ext|liveconnect
    The trace is here:
    C:\Documents and Settings\your user\Application Data\Sun\Java\Deployment\log\plugin...log
    I think for linux this is somewhere in youruserdir/java (hidden directory)
    Print out the full trace of the exception:
    try{...}catch(Exception e){e.printStackTrace();}

  • Forefront TMG disconnected a non-TCP connection

    Hi,
    I am getting the following error alerts in  TMG
    Forefront TMG disconnected a non-TCP connection from 192.168.0.1 because the connection limit for this IP address was exceeded. Larger custom connection limits should be configured for the IP addresses of chained proxy servers and back-to-back Forefront
    TMG computers with a NAT relationship. 
    This error show two msgs for my both dns servers.
    My DNS servers Ip addresses
    192.168.0.1
    192.168.0.2
    Please help me out
    Thanks

    Hi,
    How about editing the Maximum non TCP sessions per second per rule setting?
    For more information:
    http://technet.microsoft.com/en-us/library/dd441028.aspx
    Best Regards,
    Joyce
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Azure Worker Role can't receive tcp connection to Port 25(Smtp)

    I have an SMTPE implementation as an Azure Worker Role. I have defined two input endpoints (port 25 and port 2525). Listener at 2525 accepts tcp connections from smtp clients. However port 25 can't receive connections.
    When running on emulator port 25 works fine. This issue occurs when I publish my worker roles to the cloud.
    I use the same code for both. InputEndpoints are also defined the same way. The only difference is the port number.
    Is there any limitation related to port 25?

    hi sir,
    Base on my experience, Azure platform don't support out-of-the-box mail server. So I am not sure you can use SMTP on Azure cloud service. but I recommend you could refer to the
    sendgrid .Also, you can follow this documents:
    http://blog.smarx.com/posts/emailtheinternet-com-sending-and-receiving-email-in-windows-azure
    Regards,
    Will
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Many TCP connections used after 9i install

    I've installed 9i personel on XP Pro as a learning aid in advance of installing it to a real server. I notice (using "netstat") that there are now many TCP connections from my machine to localhost (also my machine) on ports from 2192 through 2267. All seem to be in a time_wait state. Are these normal and necessary?
    Thanks!

    I've installed 9i personel on XP Pro as a learning aid in advance of installing it to a real server. I notice (using "netstat") that there are now many TCP connections from my machine to localhost (also my machine) on ports from 2192 through 2267. All seem to be in a time_wait state. Are these normal and necessary?
    Thanks!

  • Get TCP connections to IP

    Hi, is there a WMI or code that can get me the number of the current TCP connections from 1 server to another one?
    Thanks

    You can use the good old Netstat.exe  to get the connections established between your PC and others.
    Maybe you can use psexec/PSRemoting to execute the netstat.exe and get the result back and parse the result.
     Hope this helps
    Knowledge is Power{Shell}.

  • Can the GPIB-ENET/100 handle multiple TCP connections?

    Can the GPIB-ENET/100 handle multiple TCP connections from multiple computers?
    -Daniel

    Yes, the GPIB-ENET/100 can handle multiple TCP connections.
    To safely access the same GPIB-ENET/100 or GPIB-ENET from multiple applications on one or more computers at the same time, use the iblck function. The iblck function prevents one application from interrupting a call made to the GPIB-ENET/100 or GPIB-ENET from another application. Without it, one application could cause an I/O operation initiated by another application to abort or cause other unexpected behavior.
    Check the NI-488.2 User Manual for more details:
    http://www.ni.com/pdf/manuals/370428a.pdf
    Winston L.
    National Instruments

  • TCP/IP Connection from ABAP

    Hello everybody.
    Does anybody know the way how to create TCP/IP connection from ABAP? I need to establish TCP/IP connection from Appication server to external server(not sap) to retrieve some data. I assume that it can be done using RFC calling technique, but i think that i have to register needed functionality as RFC in external server. To skip this step i need an explicit TCP/IP from abap.
    Thank you for helping.
    Yours sincerely,
    Nguyen Hai Long.
    Edited by: Long Nguyen on Jun 24, 2008 10:06 AM

    Thank you all. I found an example in the internet http://documentation.softwareag.com/Crossvision/sap231/pages/drfc2rpc.htm. The situation force me to overpass my laziness and to use RFC
    Yours sincerely,
    Nguyen Hai Long

  • Connecting to MySQL from an Applet

    Hi !
    I have some serious Problem connecting from within my Applet to a MySQL-DB. Everything is fine until i try to establish a Connection ( I use mm.mysql-driver ). The Driver seems to be correctly loaded, but when it comes to connection I get the following Error : Connection failed, Are you sure, that there is a MySQL-Database running at the specified target bla bla bla .....
    I guess, that it is some Problem with the Applet not beeing certified, but as it is only intended for INTRAnet use, I don't really care about security. Has anybody a quick workaroud for my Problem ?
    Thanx in advance
    Regards
    Markward Schubert

    i would try to connect to that database with application, if that fails as well then there is no applet certification problem
    usually this kind of error is printed when you try to connect to some database that is not there
    and with an applet you need to put applets binaries and database in the same server, because applet can connect only to the host where from it was loaded
    i hope that some of it helped
    L.

  • Inbound TCP connection denied from x to y

    Hi Everyone,
    Seeing following logs on ASA:
      Inbound TCP connection denied from x to y flags SYN ACK on interface Net
      Inbound TCP connection denied from x to y flags ACK on interface Net
    Does this mean that there is Asymmetric route or missing ACL?
    Regards
    MAhesh

    Hello Maheshm
    First option Asymmetric routing, use the TCP state-bypass option as a workaround.
    Remove the asymetric routing as the real fix
    Check my blog at http:laguiadelnetworking.com for further information.
    Cheers,
    Julio Carvajal Segura

  • JDBC connection to derby from an applet

    I'm doing the JDBC tutorial at java.sun.com
    Everything runs fine from the Netbeans IDE. I'm not sure whether the applet is supposed to work inside the IDE or not, I figure that's meant for the web.
    Within Netbeans, the following URL works:
    String url = "jdbc:derby:C:\\Documents and Settings\\HP_Administrator\\.netbeans-derby\\helpme";
    When I load a webpage with the applet, I get:
    java.SQLException: No suitable driver found for jdbc:derby:C:\Documents and Settings\HP_Administrator\.netbeans-derby\helpme.
    Now, I know it found the driver Class, otherwise I would have gotten Class Not Found -- so I assume its just not making the connect to the database from the applet.
    I have tried many formats for the url --
    String url = "jdbc:derby://localhost:1527/C:\\Documents and Settings\\HP_Administrator\\.netbeans-derby\\helpme";
    String url = "jdbc:derby://localhost:1527/helpme";
    String url = "jdbc:derby:helpme";
    Nothing I've tried has worked. Can someone point me in the right direction please?
    Everything is running on the same machine.

    "No suitable driver" is an error message which can indicate an improper URL. And in your case, you will want to avoid including any reference to the C: drive in your url. The format for the url can also depend upon the database you are using. So for example an mysql url would begin with
    jdbc:mysql://localhost:3306
    String url = "jdbc:derby://localhost:1527/helpme";This suggestions that you may be using a database server called derby which utilizes port 1527 and that your particular database is called helpme.
    In any case you will want to look at documentation for your particular database software ( MSAccess, MySQL, Oracle etc ) to determine how to construct the url.

  • Sharing a TCP Connection

    I have an embedded processor that opens a TCP socket to a program running on a web server and dumps real time measurements on to the server. I am trying to design an applet that opens a TCP connection to this program and thus gain access to the information dumped by the embedded system. This works fine for a single applet. But when I try doing it with several applets at a time, I run into trouble since all these applets try to read from the socket to the processor.
    My question is how do you share a single open TCP connection for reading?
    Thanks in advance.
    Prathap

    There is absolutely nothing that stops one from connecting to a single server using multiple sockets from a single application.
    So you doing something wrong in your socket code.

  • ASA 5505:Static Routing and Deny TCP connection because of bad flag

    Hi Everybody,
    I have a problem. I made a VPN site-2-site with 2 ASA 5505. The VPN works great. And I create a redondant link if the VPN failed.
    In fact, I use Dual ISP with route tracking. If the VPN fails, the default route change to an ISDN router, situated on the inside interface.
    When I simulated a VPN fail, the ASAs routes switch automatically on backup ISDN routers. If I ping elements, it works great. But when i try TCP connection like telnet, the ASAs deny connections:
    %PIX|ASA-6-106015: Deny TCP (no connection) from 172.16.10.57/35066 to 172.16.18.1/23 flags tcp_flags on interface interface_name.
    the security appliance discarded a TCP packet that has no associated connection in the security appliance connection table. The security appliance looks for a SYN flag in the packet, which indicates a request to establish a new connection. If the SYN flag is not set, and there is not an existing connection, the security appliance discards the packet.
    thanks!
    EDIT: On the schema, The interface of the main asa is 172.16.18.148...

    Check if the xlate timer is set greater than or equal to what the conn timer, so as not to have connections waiting on xlates that no longer exist. To minimize the number of attempts, enable "service resetinbound" . The PIX will reset the connection and make it go away. Without service resetinbound, the PIX Firewall drops packets that are denied and generates a syslog message stating that the SYN was a denied connection.

Maybe you are looking for

  • One account for two iPads, different content

    Hello everyone. I've got a question - I recently bought an iPad2 in addition to my first iPad, and I'm wondering if it is possible to use the same account (and the same PC) for both iPads, while having a different set of apps, photos, music and other

  • External Mic on MacBook Pro 13 inch

    I've tried doing what is recommended in the troubleshooting section, but I still can't get an external mic to work on my MacBook Pro. When I change the settings to 'Use audio port for sound input' nothing new comes up, it stays on 'Internal Microphon

  • My external drive went dead after installing Leopard

    Hey guys I'm very bummed out, my external HD went dead after installing Leopard on my Dual 2.3 GHz PowerPC G5. It was working perfectly fine before, had not a single problem with it but now, I've just lost all my work. I tried Disk Utility from the d

  • Bizarre behavior of a View Criteria for a View Object

    Hey, I remarked quite a bizarre behavior of the View criteria that I created for my view object, using bind variables. lets say I have the generated query in the View object: SELECT Paquet.ID, Paquet.WEIGHT, Paquet.VALUE, Paquet.ORIGIN, Paquet.DESTIN

  • The camera function is deleaded?

    The camera has been deleated. How can you make the camara funtiononal again?