Applet- servlet comm.

Rats!
The applet keeps throwing a security exception, saying java.io.IOException: bad path: \servlet\myServlet.
I use getCodeBase() and "/servlet/myServlet" for constructing the URL and the toExternalForm().
I used http://localhost/servlet/myServlet from the browser from the same location that the applet is and the servlet works fine.
It' s driving me crazy! It simply does not work.
Anyone managed to successfully connect an applet to a servlet either with URL, or URLConnection objects?
Can you tell me how you did it?
Chris.

umm
try it with URLConnection
This should work.
URL url = new URL("http://localhost:8080/servlet/yourservlet");
URLConnection servletConnection = url.openConnection();

Similar Messages

  • Applet Servlet Comm. Problem

    Dear friends,
    i have an applet that sends a serialized object to the servlet,the Servlet creates another object and passes it back to the applet.
    Everything works fine, till i read the object with:
    ObjectInputStream objInputStream = new ObjectInputStream(in);
            show("got object input stream");
             chart = new ChartPanel((JFreeChart)objInputStream.readObject());At this point, i got nothing back.Instead i get a "null"returned on my Java Console.
    From JBuilder it works fine
    Here is the code
    //This is called from the applet in order to load a chart in a panel
    private JPanel getChartFromServlet(Object[] parameters) throws Throwable {
      ChartPanel chart=null;
      String server;
       try {
    ///////////////////////create URL Connection to SERVLET
        if (this.remoteServerMode) {
          this.show("http://10.30.1.38:8080/AppletToServlet/DbServlet");
           server="http://10.30.1.38:8080/AppletToServlet/DbServlet";
         else {
           server="http://localhost:8083/DbServlet";
         //SEND DATA TO SERVLET
         URLConnection servletCon=this.getServletConnection(server);
         // servletCon.setRequestProperty("Content-Type","application/octet-stream");
          //send the query parameters  using serialization
           ObjectOutputStream out=new ObjectOutputStream(servletCon.getOutputStream());
           out.writeObject( parameters);
           out.flush();
           out.close();
           this.show("Finish with send to servlet");
           //GET DATA FROM SERVLET
           InputStream in=servletCon.getInputStream();
           show("got input stream");
           ObjectInputStream objInputStream = new ObjectInputStream(in);
            show("got object input stream");
             chart = new ChartPanel((JFreeChart)objInputStream.readObject());
             show("got chart");
            objInputStream.close();
            in.close();
            chart.setPreferredSize(new Dimension(734, 370));
       catch (Exception ex) {
         System.err.println("Exception caught");
         this.show(ex.getMessage());
         this.show(ex.getMessage());
         System.err.println(ex.getMessage());
         ex.printStackTrace(System.err);
       throw new Exception( ex.getCause());
    return chart;
    //Servlet Side Code
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws
          ServletException, IOException {
        ObjectInputStream inputStreamFromApplet=null;
        Object[] queryParams;
      JFreeChart chart=null;
        try {
          response.setContentType("application/x-java-serialized-object");
          //////////////////////////READ INPUT//////////////////////////////////////
          InputStream in=request.getInputStream();
          inputStreamFromApplet=new ObjectInputStream(in);
          //Read applet's serialised object passed in Input Stream
          queryParams = (Object[]) inputStreamFromApplet.readObject();
          //do something with serialized object
          chart=getRequestedChart(queryParams);
          //////////////////////////WRITE OUTPUT////////////////////////////////////
          //open an output stream
          ObjectOutputStream out = new ObjectOutputStream(response.getOutputStream());
          //write to output stream
          out.writeObject(chart);
          out.flush();
          //close output stream
          out.close();
        catch (Exception ex) {
          ex.printStackTrace();
          System.err.println(ex.getMessage());
      }Do you have any ideas?
    Apart from the null value,i saw also some SocketException
    Is there a security issue involved?Both Servlet and Applet come from the same ip.
    Thank you very much in advance,
    Chris

    A Chart constructor takes as an arg a JFreeChart.
    Chart is a JComponent so i cannot serialize it.
    That's why the servlet passes a JFreechart object and
    the applet constructs a chart from it.
    I cast the object to a jfreechart and pass it to the constructor of the chart.
    The strange thing also is that, wghile initially with a non perfectly designed UI,everything worked fine but when i modified the applet's UI ,problems started...
    Something with serialization and versions of classes?

  • Applet Servlet communication compiles but does not communicate

    Hi,
    I have a applet which has a button named A. By clicking the button, the applet passes the letter A to the servlet. The servlet in turn accesses an Oracle database and retrieves the name corresponding to letter A from a table (name is Andy in the present case). The servlet interacts with the databse via a simple stored procedure and uses its output parameter to display the name Andy back in the applet.
    Both the applet and servlet codes have compiled fine(servlet code compiled with -classpath option to servlet jar using a TOMCAT). However, on clicking button A in the applet, I do not get the name Andy.
    Any help/suggestion in resolution of this is highly appreciated. Thanks in advance.
    HTML CODE:
    <html>
    <center>
    <applet code = "NameApplet.class" width = "600" height = "400">
    </applet>
    </center>
    </html>
    STORED PROCEDURE CODE:
    procedure get_letter_description(
    ac_letter IN CHAR,
    as_letter_description OUT VARCHAR2) IS
    BEGIN
    SELECT letter_description INTO as_letter_description FROM letter WHERE letter =
    ac_letter;
    EXCEPTION
    WHEN no_data_found THEN as_letter_description := 'No description available';
    END get_letter_description;
    APPLET CODE:
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    public class NameApplet extends Applet implements ActionListener
    private TextField text;
    private Button button1;
    private String webServerStr = null;
    private String hostName = "localhost";
         private int port = 8080;
    private String servletPath = "/examples/servlet/NameServlet?letter=";
    private String letter;
    public void init()
         button1 = new Button("A");
    button1.addActionListener(this);
    add(button1);
              text = new TextField(20);
         add(text);
    // get the host name and port of the applet's web server
              URL hostURL = getCodeBase();
         hostName = hostURL.getHost();
    port = hostURL.getPort();
              webServerStr = "http://" + hostName + ":" + port + servletPath;
    public void actionPerformed(ActionEvent e)
         if (e.getSource() == button1)
         letter = "" + 'A';
    private String getName(String letter){
    String name = "" ;
    try {
              URL u = new URL(webServerStr + letter);
              Object content = u.getContent();
    name = content.toString();
         } catch (Exception e) {
         System.err.println("Error in getting name");
    return name;
    SERVLET CODE:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    import java.util.Properties;
    public class NameAppletServlet extends HttpServlet {
    private static Connection conn = null;
    private static final char DEFAULT_CHAR = 'A';
    private static final char MIN_CHAR = 'A';
    private static final char MAX_CHAR = 'G';
    private static final String PROCEDURE_CALL
    = "{call get_letter_description(?, ?)}";
    protected void doGet( HttpServletRequest request,
    HttpServletResponse response )
    throws ServletException, IOException
    handleHttpRequest(request, response);
    protected void doPost( HttpServletRequest request,
    HttpServletResponse response )
    throws ServletException, IOException
    handleHttpRequest(request, response);
    protected void handleHttpRequest( HttpServletRequest request,
    HttpServletResponse response )
    throws ServletException, IOException
    String phrase = null;
    char letter = getLetter(request, DEFAULT_CHAR);
    if (letter >= MIN_CHAR && letter <= MAX_CHAR) {
    try {
    name = getName(conn, letter);
    } catch (SQLException se) {
    String msg = "Unable to retrieve name from database.";
    name = msg;
    } else {
    String msg = "Invalid letter '" + letter + "' requested.";
    //throw new ServletException(msg);
    phrase = msg;
    response.setContentType("text/plain");
    PrintWriter out = response.getWriter();
    out.println(name);
    private String getName(Connection conn, char letter)
    throws SQLException
    CallableStatement cstmt = conn.prepareCall(PROCEDURE_CALL);
    cstmt.setString(1, String.valueOf(letter));
    cstmt.registerOutParameter(2, Types.VARCHAR);
    cstmt.execute();
    String name = cstmt.getString(2);
    cstmt.close();
    return name;
    private char getLetter(HttpServletRequest request, char defaultLetter) {
    char letter = defaultLetter;
    String letterString = request.getParameter("letter");
    if (letterString!=null) {
    letter = letterString.charAt(0);
    return letter;
    public void init(ServletConfig conf) throws ServletException {
    super.init(conf);
    String dbPropertyFile = getInitParameter("db.property.file");
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    conn = DriverManager.getConnection(
    "jdbc:oracle:thin:myserver:1521:CDD",
    "scott",
    "tiger");
    } catch (IOException ioe) {
    throw new ServletException(
    "Unable to init ReinforcementServlet: " + ioe.toString());
    } catch (ClassNotFoundException cnfe) {
    throw new ServletException(
    "Unable to init ReinforcementServlet. Could not find driver: "
    + cnfe.toString());
    } catch (SQLException se) {
    throw new ServletException(
    "Unable to init ReinforcementServlet. Error establishing"
    + " database connection: " + se.toString());
    }

    Hi,
    I am not able to understand by which method you are doing Applet-Servlet commuincation.
    If you want to use Object Serialization method, plz.get the details from following URL.
    http://www.j-nine.com/pubs/applet2servlet/
    Ajay

  • Applet/servlet communication for byte transmission

    Hello all !
    I wrote an applet to transfer binary file from web servlet (running under Tomcat 5.5) to a client (it's a signed applet) but I have a problem of interpretation of byte during transmission.
    the code of the servlet is :
            response.setContentType("application/octet-stream");
            ServletOutputStream sos = response.getOutputStream();
            FileInputStream fis = new FileInputStream(new File(
                    "C:\\WINDOWS\\system32\\setup.bmp"));
            byte[] b = new byte[1024];
            int nbRead = 1;
            while (nbRead > 0) {
                nbRead = fis.read(b);
                System.out.println("octets lus = " + nbRead);
                sos.write(b, 0, nbRead-1);
            fis.close();
            sos.close();et le code de l'applet qui appelle cette servlet est :
            URL selicPortal = null;
            try {
                selicPortal = new URL(
                        "http://localhost:8080/AppletTest/servlet/FileManipulation");
            } catch (MalformedURLException e) {
                e.printStackTrace();
            URLConnection selicConnection = null;
            try {
                selicConnection = selicPortal.openConnection();
            } catch (IOException e) {
                e.printStackTrace();
            selicConnection.setDoInput(true);
            selicConnection.setDoOutput(true);
            selicConnection.setUseCaches(false);
            selicConnection.setRequestProperty("Content-Type",
                    "application/octet-stream");
            try {
                InputStream in = selicConnection.getInputStream();
                FileOutputStream fos = new FileOutputStream(new File(tempDir
                        + "\\toto.bmp"));
                byte[] b = new byte[1024];
                int nbRead = in.read(b);
                while (nbRead > 0) {
                    fos.write(b);
                in.close();
                fos.close();
             } catch (IOException ioe) {
                ioe.printStackTrace();
            }the file dowloaded is broken. it seems that bytes 01 00 or 00 01 are not correctly process.
    Some ideas to help me please ?

    hi,
    have you solved this issue.. please post me the code since i m also doing the applet/servlet communication and can use your code as reference.
    how to read the content placed in the urlConnection stream in the servlet
    Below is my code in applet
    public void upload(byte[] imageByte)
              URL uploadURL=null;
              try
                   uploadURL=new URL("<url>");
                   URLConnection urlConnection=uploadURL.openConnection();
                   urlConnection.setDoInput(true);
                   urlConnection.setDoOutput(true);
                   urlConnection.setUseCaches(false);
                   urlConnection.setRequestProperty("Content-type","application/octet-stream");
                   urlConnection.setRequestProperty("Content-length",""+imageByte.length);
                   OutputStream outStream=urlConnection.getOutputStream();
                   outStream.write(imageByte);
                   outStream.close();
              catch(MalformedURLException ex)
              catch(IOException ex)
    How can i read the byte sent on the outstream (in above code) in the servlet.
    Thanks,
    Mclaren

  • Asynchronous applet-servlet communication

    Hi all,
    I am trying to implement asynchronous applet-servlet communication and need your help. Anything would help(I tried with synchronous applet-servlet communication but doesn't solve my problem).
    Thanks,

    http://java.sun.com/docs/books/tutorial/networking/index.html
    You can open a socket connection. Bother the client and the server
    can have separate threads for reading and writing and that you gives you
    asynchronous communication. Later, if you think the server is generating
    too many threads and not scaling, you can use features of .java.nio to
    make it more scalable:
    java.nio.channels

  • Is there a good advanced review on applet-servlet communication

    I am working on a web application and unfortunately experiencing a lot of trouble trying to use an applet as front end which interacts with a couple of servlets running on Tomcat. I need to get data from one servlet and send data to another.
    There is a lot of messages posted in this and other forums about how to do this, but none of them got a response pointing to a useful advanced reference on this subject. I have reviewed some of the references given, but couldn't find a thorough detailed advanced reference on applet-servlet communication. For this I mean an exhaustive explanation of the mechanism of communication and when and when is neccesary to use each of the multiple configuration possibilities regarding content-type, message-length, request-method, connection settings, and so on.
    Would anybody be so kind to show me the right direction? As I read the (literally) hundreds of messages posted on this topic, I see this info as widely useful. Most of the topic tracks ends on void or with painful no-way sentences, and maybe many people is avoiding Java technology on web application because of this problem (development delays can abort a project).

    This sample chapter in Java developers' guide to Servlets and Jsp focuses on Applet-Servlet communication, is a pretty good one, and is free :
    http://www.javaranch.com/bunkhouse/samps/2809ch12.pdf
    As to an exhaustive & complete guide that covers absolutely everything, I may be wrong but I doubt you'll find anything like that...unless there is a book somewhere dedicated to the subject.

  • Applet-servlet communication, object serialization, problem

    hi,
    I encountered a problem with tomcat 5.5. Grazing the whole web i didn't find any solution (some guys are having the same problem but they also got no useful hint up to now). The problem is as follows:
    I try to build an applet-servlet communication using serialized objects. In my test scenario i write a serialized standard java object (e.g. a String object) onto the ObjectOutputStream of the applet/test-application (it doesn't matters wheter to use the first or the latter one for test cases) and the doPost method of the servlet reads the object from the ObjectInputStream. That works fine. But if i use customized objects (which should also work fine) the same code produces an classnotfound exception. When i try to read and cast the object:
    TestMessage e = (TestMessage)objin.readObject();
    java.lang.ClassNotFoundException: TestMessage
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    ...That seems strange to me, because if i instantiate an object of the same customized class (TestMessage) in the servlet code, the webappclassloader doesn't have any problems loading and handling the class and the code works fine!
    The class is located in the web-inf/classes directory of the application. I've already tried to put the class (with and without the package structure) into the common/classes and server/classes directory, but the exception stays the same (I've also tried to build a jar and put it in the appropriate lib directories).
    I've also tried to catch a Throwable object in order to get information on the cause. But i get a "null" value (the docu says, that this will may be caused by an unknown error).
    I've also inspected the log files intensively. But they gave me no hint. Until now I've spend a lot of time on searching and messing around but i always get this classnotfound exception.
    I hope this is the right place to post this problem and i hope that there is anyone out there who can give me some hint on solving this problem.
    Kindly regards,
    Daniel

    hi, thanks for the reply,
    all my classes are in the web-inf/classes of the web-app and have an appropriate package structure. thus the TestMessage class is inside a package.
    i tried some names for the testclass but it didn't matter. the exception stays the same. I also tried to put the jar in the common/lib but the problem stays.
    Well the problem with loaded classes: As i mentioned in the post above i can instantiate an object of TestMessage in the code without any problems (so the classloader of my webapp should know the class!!)
    only when reading from the objectinputstream the classloader doesn't seem to know the class?? maybe theres a parent classloader resposible for that and doesn't know the class?
    strange behaviour...
    p.s. sending the same object from the servlet to the client works well
    regards
    daniel
    Message was edited by:
    theazazel

  • Applet-Servlet or RMI - which is better

    We are in the process of developing a swing-applet based system that requires regular interaction with multiple databases residing on more than one database server.
    The options available before us, as we evaluate are:
    a. Use "signed" applets ( as this is going to be essentially an intra-net application) and use JDBC connection to connect to more than one database ( which reside on servers other than the web server).
    b. Use applet - servlet communication - basically, the servlet would establish connection to the databases, directly or through EJB, retrieve necessary database information and pass on the objects to the applet - the front end GUI would be controlled by the applet.
    c. Use RMI
    We would like to have your perspective of the three options, with your experience in this line.
    The questions that come to us are:
    a. If the system is essentially an intra-net application, is it okay to design with "signed" applet mechanism - how far is this method common in the market and acceptable to the clients? Is it true that the signed applet would be able to establish connection to various "identified servers" that are allowed permissions in the security file?
    b. Between applet-servlet and RMI, which is a better method? What should be the factors that need to be considered? Is RMI being widely used or should we be thinking in terms of EJB, eventhough the current project is purely a Java based solution.
    Your input is highly appreciated - thanking in advance for any suggestions and inputs that you may provide.
    Thanks
    Dixie

    Dixie,
    1) IMHO signed applets are not widely used, but you can use
    ordinary applets, which are accessing other resources through
    redirector servlet on server side - I mean ordinary applets
    are prohibited to establish connect to other than it's own server.
    So you will be forced to have special servlet on your server,
    which have access to other resources on other servers - this is a
    way how to avoid applets limitation.
    2) RMI is a heavy solution, because all parameters/objects should
    be serialized over net and if network connection is unreliable
    working with system will be just a nighmare.
    3) If you think that your network connection is unreliable, you can use HTTP protocol between client and server instead of RMI. In this case
    you will have following benefits:
    i) You can still use all of powerness of thick client
    ii) Network unreliability will be defeated
    iii) Sometime if you would like to port your application to a thin
    client it will be done much more easier than in case of RMI
    4) If you would like to use thin client your only problem will
    be poorness of UI - if you can go with it - go ahead! Otherwise
    use thick client with RMI or HTTP depending on quality of network.
    Paul

  • Applet/Servlet communication - StreamCorruptedException

    Hi, I'm having a problem when I try to connect to a servlet. I am using applet/servlet communication. The problem only occurs when I have lauched a crystal report via http in a new window.
    After the report is launched if I try to hit my servlet I get the following error:
    java.io.CorruptedStreamException: invalid stream header
    Not all crystal reports I launch cause this behavior but I can see nothing in the url I use to launch the report that is out of place or different than other reports.
    APPLET-SERVLET CONNECTION
    try {
    StringBuffer path = new StringBuffer();
    path.append(ip);
    path.append("servlet/DatabaseServlet?");
    path.append("option=getRecords&query=").append(URLEncoder.encode(query,"UTF-8"));
    URL url = new URL(path.toString());
    URLConnection servletConnection = url.openConnection();
    servletConnection.setUseCaches(false);
    servletConnection.setDoInput(true);
    servletConnection.setDoOutput(true);
    servletConnection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
    ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
    rc = (RecordCollection) inputFromServlet.readObject();
    inputFromServlet.close();
    } catch (Exception e) {
    e.printStackTrace();
    SERVLET CODE
    Forwards to doPost
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    System.out.println("session id: " + request.getSession().getId());
    this.doPost(request, response);
    LAUNCHING REPORT FROM APPLET
    try {
    String launchURL = host + directory + report + "?promptOnRefresh=0"+ "&" +
    authentication + "&" + key + "&" + startPeriods + "&" + reportYears + "&" + reportTitle + "&" endPeriods "&" + locations + "&" + reportPeriod + "&" + fiscalWeek + "&" + fiscalYear + "&" +time;
    context.showDocument(new URL(launchURL), "_blank");
    } catch (Exception ex) {
    ex.printStackTrace();
    SAMPLE URL THAT CAUSES PROBLEM
    http://localhost:113/Reports/OpenToBuy_3.class?promptOnRefresh=0&user0=rpuser&password0=er34sw1&[email protected]=rpuser&[email protected]=er34sw1&user0@sub2=rpuser&[email protected]=er34sw1&promptex-key="L","L1","ALL"&promptex-start="1"&promptex-years="2004","2004"&promptex-title="Report Title"&promptex-end="1"&promptex-locs="01","03","04","05"&promptex-period="Feb 2004 [04-01]"&promptex-cw="1"&promptex-cy="2004"&promptex-time=-2-52728"
    Everything works fine until I launch this report then I can no longer get data from my servlet. I thought the URL lenght for the report might be the problem but I lauch a report with a URL longer than the problem one and there I don't get the errors after. When I try to connect to the servlet the println statement in the doGet method of my servlet doesn't get printed so it's not even making it inside that method in the servlet.
    Anyone have any idea what could be causing this? Anyone have any ideas what would be causing this? I'm really stumped.

    I've seen this problem before. Because your accessing a complete URL (ie http://<host>:<port>/xxx), you are actually creating a new session. Whenever the applet opens a connection to a servlet it is running on it's own session not the same as the JSP. This is rather obvious since the Page and Applet are separate entities.
    Try sending authentication with the url. I think the syntax is:
    username:password@http://localhost/xxx
    However I'm not sure how well this might work for Tomcat. As for Java it may try and throw a MalformedURLException I would have to test it first - it's been a long time since I used this technique!
    Wish I could be more help,
    Anthony

  • Can i use Web Start for applet servlet architecture

    Hello ,
    I am currently working on conversion of swings GUI to applet based so that it can be accessed any where from the network.
    Presently its a standalone application, requiring installation of the work station component on user's machine .This would access the database on other server using the JDBC ODBC drivers.The GUI would display the information from the database.
    The task is to make it accesible remotely using a webbrowser.I have thought of the following.
    1.
    Applet-->Servlet--->Database architecture
    I was wondering if i can do the same functionality with Webstart. I mean will i be able to deploy the present application and make connections to the host server.
    Please compare the options .

    No , this is not supported by Oracle.
    Regards Anders Northeved

  • How to show progress - Applet - Servlet

    Hi,
    I am new to applet-servlet communication. I have to show the progress at the applet front-end using a JProgressBar for a task being done at the servlet end. I request the gurus on the forum to post any example code for the above situation.

    Hi,
    U will have to use the SwingWorker to popup the JProgressBar, but in here i dont think u will be getting any input from servlet giving the job completed, if u are using jdk1.4.1 u can use
    setIndeterminate(true);
    I am attaching 2 methods below which i use to display the JProgressBar
    Method long task is where i actually call the servlet and in method buildData i create the URLConnection etc
    //appletData must implement Serializable
    public void buildData(Object appletData)throws Exception
    //define servlet name here
    ObjectInputStream inputFromServlet = null;
    URL          studentDBservlet = new URL("MyServlet");
    URLConnection servletConnection = studentDBservlet.openConnection();
    servletConnection.setDoInput(true);
    servletConnection.setDoOutput(true);
    servletConnection.setUseCaches(false);
    servletConnection.setRequestProperty("Content-Type", "application/octet-stream");
    ObjectOutputStream outputToServlet =
              new ObjectOutputStream(servletConnection.getOutputStream());
         // serialize the object
         if (!SwingUtilities.isEventDispatchThread())
              outputToServlet.writeObject(input);
              outputToServlet.flush();
              outputToServlet.close();
              inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
         else
              inputFromServlet = longTask(servletConnection, outputToServlet, appletData);
    private ObjectInputStream longTask(final URLConnection servletConnection,
                        final ObjectOutputStream outputToServlet,
                        final Object appletData)
         final JDialog dialog = new JDialog(PlanApplet.appletFrame, "Please Wait", true);
    isProcess = true;
         MapsPanel panel = new MapsPanel();
         panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
         //MapsLabel label = new MapsLabel("Work in process....");
    //label.setFont(Constant.bigFont);
         //label.setPreferredSize(new Dimension(230, 40));
         JProgressBar progressBar = new JProgressBar();
         progressBar.setIndeterminate(true);
         progressBar.setPreferredSize(new Dimension(140, 30));
    // final JugglerLabel jugLabel = new JugglerLabel();
    // jugLabel.startAnimation();
    // panel.setPreferredSize(new Dimension(175, 175));
         MapsPanel progressPanel = new MapsPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
         progressPanel.setPreferredSize(new Dimension(140, 80));
    progressPanel.add(progressBar);
    //     progressPanel.add(jugLabel);
    //     panel.add(Box.createVerticalStrut(5));
         //panel.add(label);
         panel.add(Box.createVerticalStrut(15));
         panel.add(progressPanel);
         panel.add(Box.createVerticalStrut(15));
         dialog.setSize(150, 115);
         dialog.setResizable(false);
    //     dialog.getContentPane().add(jugLabel);
    dialog.getContentPane().add(panel);
    dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dialog.setLocation(ScreenSize.getDialogLocation(dialog));
    //      final javax.swing.Timer popupTimer = new javax.swing.Timer(2000, new TimerListener(dialog));
         final SwingWorker worker = new SwingWorker()
         public Object construct()
              try
              PlanApplet.applet.setCursor(new Cursor(Cursor.WAIT_CURSOR));
              outputToServlet.writeObject(appletData);
              outputToServlet.flush();
              outputToServlet.close();
              return new ObjectInputStream(servletConnection.getInputStream());
              catch (Exception exc)
              return null;
         public void finished()
    // jugLabel.stopAnimation();
              dialog.dispose();
    Toolkit.getDefaultToolkit().beep();
    isProcess = false;
              LogWriter.out("the long process is finished", LogWriter.BASIC);
         worker.start();
    // popupTimer.start();
         //System.out.println("Process complete");
         dialog.show();
    // while(isProcess)
         return (ObjectInputStream) worker.getValue();

  • Communication between Applets & Servlets

    How do you communicate in between Applets & Servlets ?

    http://forum.java.sun.com/thread.jsp?forum=45&thread=525518&start=0&range=15#2519429

  • Applet+servlet+standards

    Hi there,
    I am relatively new at java and i was asking myself one question :
    let's say i have an applet that "post" to a servlet to validate login and password against a database (so far it works well), what is the mean by wich (if the login password combination is good), i go to the next stage e.g. open a new applet-servlet combination ?
    I used to program with vbscript in .asp page (i know.....), and in that language there was the instruction redirect that allowed to redirect to another page when the results were being considered "valid", but i'm not sure that it is te way to do it in the applet-servlet world ...
    Any hints, tricks,approach, are welcome......
    thank you to all

    The servlet API includes a method to redirect a client to a new webpage. For example:
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
        // do validation
        // redirect client
        response.sendRedirect(redirectURL);
    }

  • EOF exception during applet - servlet communication

    I am developing a system for the US Gov't. This system currently
              utilizes several applets which access corresponding servlets on
              WebLogic. Seemingly, things went wrong for no apparent reason this
              morning. When, trying to run our applets, WebLogic throws an exception:
              "Caught EOFException in the stream header" These exceptions occur
              everytime the servlet would open the input stream from the applet. What
              makes things mind-boggling is that these applets/servlets were working
              this morning, and suddenly now give these exceptions. The code for both
              the applets and servlets has not been touched in weeks. Furthermore, i
              tested even further by running WebLogic locally and running the applets
              in our IDE (as applications) and the same results occur. I am running
              WebLogic 5.1 SP6 on both the remote and local system and am utilizing
              JDK 1.3 on both as well. The server is running on WinNT SP6 and locally
              is Win2000 Pro SP1. These applets are critical to the entire system and
              i am just totally baffled as to why something that was working fine one
              day ago should all of the sudden spit up errors and exceptions.
              If anyone can give me some insight as to what is going on, please let me
              know.
              Thank you,
              Randy Strobel
              [email protected]
              

    Randy,
              I don't know of any particular reasons why WebLogic would suddenly affect an
              application in the manner that you describe. Start by figuring out where
              the message comes from:
              > "Caught EOFException in the stream header"
              I assume that is in WebLogic's code, not yours? Figure out as close as
              possible who is detecting this error condition. If it is in WebLogic's
              code, you can ask support at BEA to tell you what it is complaining about
              (i.e. what it is expecting to read).
              You will have to post the exception trace here and it would help to see the
              code that is causing the exception.
              Cameron Purdy
              Tangosol, Inc.
              http://www.tangosol.com
              +1.617.623.5782
              WebLogic Consulting Available
              "Randy Strobel" <[email protected]> wrote in message
              news:[email protected]...
              > I am developing a system for the US Gov't. This system currently
              > utilizes several applets which access corresponding servlets on
              > WebLogic. Seemingly, things went wrong for no apparent reason this
              > morning. When, trying to run our applets, WebLogic throws an exception:
              > "Caught EOFException in the stream header" These exceptions occur
              > everytime the servlet would open the input stream from the applet. What
              > makes things mind-boggling is that these applets/servlets were working
              > this morning, and suddenly now give these exceptions. The code for both
              > the applets and servlets has not been touched in weeks. Furthermore, i
              > tested even further by running WebLogic locally and running the applets
              > in our IDE (as applications) and the same results occur. I am running
              > WebLogic 5.1 SP6 on both the remote and local system and am utilizing
              > JDK 1.3 on both as well. The server is running on WinNT SP6 and locally
              > is Win2000 Pro SP1. These applets are critical to the entire system and
              > i am just totally baffled as to why something that was working fine one
              > day ago should all of the sudden spit up errors and exceptions.
              >
              > If anyone can give me some insight as to what is going on, please let me
              > know.
              > Thank you,
              > Randy Strobel
              > [email protected]
              >
              >
              

  • Communication Applet - Servlet

    Hello,
    I'm trying to do a communication Applet - Servlet.
    When i'm typing in my browser internet explorer
    http://pcsm1:8080/servlet/MyServlet
    My servlet is invoqued perfectly and i see the good message in the prompt ms-dos (cf MS-DOS PROMPT : MESSAGE OF THE SERVLET!)
    But when i'm trying with my applet, i have a security exception : cannot access "pcsm1":8080
    SERVLET :
    public class MyServlet extends HttpServlet
    public void init(ServletConfig config)
    System.out.println("Servlet Init");
    public void doGet(HttpServletRequest request,HttpServletResponse response)
    ObjectOutputStream outputToApplet;
    long data=69;
    try
    outputToApplet = new ObjectOutputStream (response.getOutputStream());               System.out.println("Sending data to applet...");
    outputToApplet.writeLong(data);
    outputToApplet.flush();
    outputToApplet.close();
    System.out.println("Data transmission complete.");
    catch (IOException e)
    public void doPost(HttpServletRequest request,HttpServletResponse response)
    APPLET :
    public class MyApplet extends Applet
    public void init()
    try
    URL url = new URL("http://pcsm1:8080/servlet/MyServlet");
    or
    URL url = new URL(getCodeBase(),"http://pcsm1:8080/servlet/MyServlet");
    URLConnection servletConnection = url.openConnection();
    servletConnection.setDoInput(true);
    servletConnection.setDoOutput(true);
    servletConnection.setUseCaches (false);
    servletConnection.setDefaultUseCaches (false);
    servletConnection.setRequestProperty("Content-type","application/octet-stream");
    ObjectInputStream inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
    data = inputFromServlet.readLong();
    inputFromServlet.close();
    catch (Exception e)
    MS-DOS PROMPT : MESSAGE OF THE SERVLET
    when caller is internet explorer
    C:\Servlet\bin>servletrunner -d "c:\servlet\bin"
    servletrunner starting with settings:
    port = 8080
    backlog = 50
    max handlers = 100
    timeout = 5000
    servlet dir = c:\servlet\bin
    document dir = .\examples
    servlet propfile = c:\servlet\bin\servlet.properties
    Servlet Init
    Sending data to applet...
    Data transmission complete.
    What can i do to avoid my security exception problem?
    Very thanks...

    Are MyServlet and the HTML page hosting MyApplet being served from the same server (i.e., pcsm1:8080)? If not, this is a violation of one of the security constraints placed on unsigned applets.
    If the above scenario is the case, there are three options to overcome:
    1) Create a signed applet
    2) Move the HTML/Applet to the same server as the Servlet
    3) On the server serving the HTML/Applet, create a "proxy" servlet to which the applet can connect and which will in turn contact MyServlet (through HttpURLConnection)

Maybe you are looking for

  • Kenwood X991 & iP200 cable with iPod 5th Gen 80GB does NOT work correctly

    I have a conundrum. My wife has the 4th Gen v1.2.1 iPod 30GB which works fine on my Kenwood X991 Head Unit. I recently purchased the "new" 80GB iPod 5th Gen with the latest version "1.0.2" which does NOT work properly. The iTunes software tells me th

  • Opening a new tab in Firefox 16.0.1 the focus is on the address bar but then moves to the search field

    When I open a new tab in Firefox 16.0.1 the focus is on the address bar for a second or so then the focus moves to the search input field. If I start typing something the first character fills in the address bar then the rest is typed into the search

  • External monitor not detected

    I just got a Samsung SyncMaster 2033 SW Plus monitor and tried connecting through the DVI port of my MacBook Pro, but its not getting detected. I'm using the mini display port to DVI adapter to connect. The monitor seems to work perfectly when I conn

  • Crystal reports - Create Report from SAP Bex Query

    I have installed the Crystal reports 2008 for a trial period and the sap integration kit. I have created a new report from a sap query and I am trying to format the report. I would like the columns headings be similar to Bex query - Current Month Jan

  • MacBook Pro Grey screen 4-8x a night

    Over the past week my computer just pauses then restarts to the logon screen...usually the computer does this once or twice but this is very consistent 4-8x a day.  I have a MacBook Pro 3,1; 2.2 GHz core duo, 4 gb ram,  system 10.6.8 Any help?  This