Java Applet or Servlets

Hi
I have been developing a data driven web system . The database is done using SQL Server 2000 . I will build the user interface using Java & Coldfusion for the user to get data from the database in the form of a URL . I wonder which technology to choose from between Java Servlets or Java Applets to develop this systems .
Any Hekp in this regard is appriciated
Thanks

In my experience Applets can be a pain in the butt,
especially for naive users. The problem is getting
the right plugin.it's usually a political decision more than anything.
In theory you can set up your HTML to load the plugin
autmatically but often you may find users don't have
the necessary permissions to do what is effectively a
software installation. And different browsers have
different levels of user friendliness in the
installation procedure.In IE, it can auto-install, with the user's permission, of course. In Netscape/Mozilla or others, you need to do it manually.
In theory, if you confined yourself to Window you
could use the MS java engine, but it no longer
appears in every installation and it doesn't do
swing.You can, but, the MS JVM:
1) Is Java version 1.1.4 (You can get compatible Swing and Collections JARs, but that's just another big chunk of stuff to download, especially the Swing one).
2) Has bugs and security holes which will never be fixed (unless more extremely critical security flaws are found).
3) No longer comes on new installations of Windows XP SP1a or higher or Windows 2003 Server anyway. Future OS releases will not contain it ever again.
4) Is to be officially retired in Dec 2007 (It was to be Sept 2004, but was pushed back).
My advice is not to use applets without a very good
reason, especially if you are looking at a large
non-expert user base. Usually the HTML form system,
with a bit of Java Script to liven it is, is more
than adequate for most database activities.Depends on the goal of the application. There's lots of things applets can do that Flash or DHTML just can't. There's lots of things that Flash or DHTML are a lot better for or faster to develop.
I don't think the description of the proposed project really indicates a preference for either, actually. I mean, it could lean one way or the other, but I just don't see what that is.

Similar Messages

  • SeaMonkey v2.0.4's Java applets doesn't work all the time.

    Hello. I use Mozilla's SeaMonkey v2.0.4 (using binary from mozilla.org) in Debian/Linux. I can get Java applets to work on https://eetime11.adp.com/c08e/logon but not on http://javatester.org, http://java.com/en/download/installed.jsp, and http://java.com/en/download/help/testvm.xml
    Java Plug-in 1.6.0_20
    Using JRE version 1.6.0_20-b02 Java HotSpot(TM) Client VM
    User home directory = /home/ant
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    p: reload proxy configuration
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    load: class testvm2/Main.class not found.
    java.lang.ClassNotFoundException: testvm2.Main.class
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    FYI on my setups:
    $ pwd
    /home/Programs/seamonkey2/plugins
    $ ls -all
    total 28
    drwxr-xr-x 2 ant ant 4096 2010-04-15 15:46 .
    drwxr-xr-x 15 ant ant 4096 2010-04-16 08:32 ..
    lrwxrwxrwx 1 root root 32 2009-11-27 17:19 libflashplayer.so -> /home/Programs/libflashplayer.so
    lrwxrwxrwx 1 root root 63 2010-04-15 15:46 libjavaplugin_oji.so -> /home/Programs/jre1.6.0_20/plugin/i386/ns7/libjavaplugin_oji.so
    -rwxr-xr-x 1 ant ant 15824 2009-10-17 09:30 libnullplugin.so
    $ ls -all /home/Programs/jre1.6.0_20/plugin/i386/ns7/libjavaplugin_oji.so
    -rwxr-xr-x 1 ant ant 137021 2010-04-12 14:39 /home/Programs/jre1.6.0_20/plugin/i386/ns7/libjavaplugin_oji.so
    Does anyone know why? Thank you in advance. :)
    Edited by: antdude on Apr 16, 2010 8:37 AM

    More poking around:
    $ java -version
    java version "1.6.0_18"
    OpenJDK Runtime Environment (IcedTea6 1.8pre) (6b18~pre2-1)
    OpenJDK Server VM (build 14.0-b16, mixed mode)
    # dpkg -l | grep ^ii |grep java
    ii ca-certificates-java 20091021 Common CA certificates (JKS keystore)
    ii java-common 0.35 Base of all Java packages
    ii libaccess-bridge-java 1.26.2-4 Java Access Bridge for GNOME
    ii libaccess-bridge-java-jni 1.26.2-4 Java Access Bridge for GNOME (jni bindings)
    ii libhsqldb-java 1.8.0.10-6 Java SQL database engine
    ii liblucene2-java 2.9.2+ds1-1 Full-text search engine library for Java(TM)
    ii libservlet2.4-java 5.0.30-12 Servlet 2.4 and JSP 2.0 Java library
    ii openoffice.org-java-common 1:3.2.0-4 full-featured office productivity suite -- arch-independent Java support files
    ii tzdata-java 2010h-1 time zone and daylight-saving time data for use by java runtimes
    # dpkg -l | grep ^ii |grep jre
    # locate bin/java
    /home/Programs/jre1.6.0_20/bin/java
    /home/Programs/jre1.6.0_20/bin/java_vm
    /home/Programs/jre1.6.0_20/bin/javaws
    /usr/bin/java
    /usr/bin/javaws
    /usr/lib/jvm/java-6-openjdk/bin/java
    /usr/lib/jvm/java-6-openjdk/bin/java-rmi.cgi
    /usr/lib/jvm/java-6-openjdk/bin/javaws
    /usr/lib/jvm/java-6-openjdk/jre/bin/java
    /usr/lib/jvm/java-6-openjdk/jre/bin/javaws
    /usr/lib/jvm/java-6-openjdk/jre/bin/javaws.real
    I tried to uninstall all the unneccesary Java packages, but still had some can't be removed because of other programs requiring it like OpenOffice:
    # apt-get remove openjdk-6-jre-headless
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
    openoffice.org-filter-mobiledev ttf-sil-gentium ttf-sil-gentium-basic
    Use 'apt-get autoremove' to remove them.
    The following packages will be REMOVED:
    ca-certificates-java libaccess-bridge-java libaccess-bridge-java-jni libhsqldb-java liblucene2-java libservlet2.4-java
    openjdk-6-jre openjdk-6-jre-headless openjdk-6-jre-lib openoffice.org openoffice.org-base openoffice.org-officebean
    openoffice.org-report-builder-bin
    0 upgraded, 0 newly installed, 13 to remove and 125 not upgraded.
    After this operation, 114MB disk space will be freed.
    Do you want to continue [Y/n]? n
    Abort.
    # apt-get remove java-common
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages were automatically installed and are no longer required:
    openoffice.org-filter-mobiledev ttf-sil-gentium ttf-sil-gentium-basic
    Use 'apt-get autoremove' to remove them.
    The following packages will be REMOVED:
    ca-certificates-java java-common libaccess-bridge-java libaccess-bridge-java-jni libhsqldb-java liblucene2-java
    libservlet2.4-java openjdk-6-jre openjdk-6-jre-headless openjdk-6-jre-lib openoffice.org openoffice.org-base
    openoffice.org-officebean openoffice.org-report-builder-bin
    0 upgraded, 0 newly installed, 14 to remove and 125 not upgraded.
    After this operation, 115MB disk space will be freed.
    Do you want to continue [Y/n]? n
    Abort.
    Any ideas? :(

  • Forms Client Java Applet waiting several minutes

    Hello,
    We use Forms 10.1.2.0 and html/javascript/plsql applications.
    All forms applications are working but
    we have the problem that from time to time the client java applet must wait minutes until there is an answer from the forms-servlet (especially when there is high activity in the system).
    More than one user is working in the form with high activity - the applet sends a request
    over the network - after 4 minutes the result is shown and you can go on working
    without problems.
    So a lot of users think the application has crashed and terminate before.
    The applet shows no error messages.
    There is no sign that there is a lost connection between applet and servlet.
    It is not reproducible. That means you can work 2 hours and everything is ok
    or you work 5 minutes and you have to wait.
    network problems?
    firewall problems?
    do requests of the forms servlet to the database have minor priority on the application server
    than html/plsql requests?
    any ideas?

    when the problem occurs (user has to wait 3-4 minutes) we found in the log
    3 heartbeats from the forms client within 2 seconds ?
    after 3-4 minutes the forms client is ok (user can go on working)
    and the pings are every 2 minutes (like it is expected).
    The application.log file may contain duplicate posts requests with
    identical pragma header numbers, indicating that the client
    is resending
    requests due to network packet losses. Under normal circumstances,
    only the last Post request, terminating a Forms session,
    should contain
    a duplicate pragma header number.
    ...a network problem ?
    anyone else who had the same problem ?

  • How can i convert java application of bibeans to java applet?

    Hi Bibeans PMTeam,
    Bibeans provide two type client:java application and web client(JSP/Servlet),because web client's function is weaker than java app,so we want to convert java app to java applet,thus,we can embed java applet into web browser(our system framework is in web browser).
    That is,we want one applet client that commution with a server side service(can by socket,just like oracle 9i form service)that provide the data that applet need,or the applet connect to olap server and bibeans catalog server by socket(this need security authentication if olap server,bibeans catalog,web server is not in one machine).
    so we need you provide whole resolve scheme,thanks a lot,if this answer is not clarity,please connect:[email protected],thanks a lot!

    hi tomsong
    well, in my experience 20mb are quite large for an applet. also take into account that you need a certain jvm that supports this type of application (my guess is that internet explorers native vm isnt an option)
    i personally would tend to deliver the functionality via java webstart (look at the sunsite):so you can centrally manage the software, download it once and opertae an application on your client (i mean an APPLICATION and not an applet)
    regarding 2: well but there is NO bibean service in ias: so you have to open the former mentioned jdbc connection to the olap service from your client
    for the availability: you have to check with the pm team
    in the meantime: what about the following approach: give power users a java application and lightweight or random users a handy html client ?
    regards,
    thomas

  • Sending a file from Applet to servlet HELP me Please

    Sorry, i have the problem this is my code Applet & Servlet but it seems working asynchronously if you have some ideas please reply me i send bytes on outputstream but the inputstream of servlet receive nothing bytes but write my system.out.print on screen server:
    Applet:
    URL servletURL = new URL(codebase, "/InviaFile/servlet/Ricevi");
    HttpURLConnection urlConnection = (HttpURLConnection) servletURL.openConnection();
    urlConnection.setRequestMethod("POST");
    urlConnection.setUseCaches(false);
    urlConnection.setDoOutput(true);
    urlConnection.setDoInput(true);
    urlConnection.setAllowUserInteraction(false);
    urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
    urlConnection.setRequestProperty("Content-length", String.valueOf(100));
    urlConnection.connect();
    if(urlConnection.HTTP_BAD_REQUEST == HttpURLConnection.HTTP_BAD_REQUEST){
    /*System.out.println("Cattiva Richiesta: "+urlConnection.getContentEncoding());
    System.out.println("Tipo di metodo: "+urlConnection.getRequestMethod());
    System.out.println("Tipo di Risposta: "+urlConnection.getResponseCode());
    System.out.println("Tipo di messaggio: "+urlConnection.getResponseMessage());
    System.out.println("Tipo di contenuto: "+urlConnection.getContentType());
    System.out.println("Tipo di lunghezza contenuto: "+urlConnection.getContentLength());
    System.out.println("Tipo di doinput: "+urlConnection.getDoInput());
    System.out.println("Tipo di doouput: "+urlConnection.getDoOutput());
    System.out.println("Tipo di URL: "+urlConnection.getURL());
    System.out.println("Tipo di propriet� richiesta: "+urlConnection.getRequestProperty("Content-Type"));
    System.out.println("Entra if");
    DataOutputStream dout = new DataOutputStream(urlConnection.getOutputStream());
    InputStream is = urlConnection.getInputStream();
    if(ritornaFile("C:/Ms.tif", dout))System.out.println("Finita lettura");
    dout.close();
    urlConnection.disconnect();
    System.out.println("Fine Applet");
    }catch(Exception e) { System.err.println(e.getMessage());e.printStackTrace();}
    public boolean ritornaFile(String file, OutputStream ots)throws Exception{
    FileInputStream f = null;
    try{
    f = new FileInputStream(file);
    byte[] buf = new byte[4 * 1024];
    int byteLetti;
    while((byteLetti = f.read()) != -1){ots.writeByte(buf, 0, byteLetti);ots.flush();
    while((byteLetti = f.read()) != -1){ots.write(byteLetti);ots.flush();
    System.out.println("byteLetti= "+byteLetti);
    return true;
    }catch(Exception ex){
    System.err.println(ex.getMessage());
    return false;
    }finally{
    if(f != null)f.close();
    Servlet:
    HttpSession ses = request.getSession(true);
    System.out.println("Passa servlet "+request.getMethod());
    System.out.println("Passa servlet "+ses.getId());
    ServletInputStream servletinputstream = request.getInputStream();
    DataInputStream dis = new DataInputStream(request.getInputStream());
    int c = dis.available();
    System.out.println("c="+c);
    //ServletOutputStream servletoutputstream
    //response.getOutputStream();
    response.setContentType("application/octet-stream");
    System.out.println("URI= "+request.getRequestURI());
    System.out.println("pathTranslated: "+request.getPathTranslated());
    System.out.println("RemoteUser: "+request.getRemoteUser());
    System.out.println("UserInRole: "+String.valueOf(request.isUserInRole("")));
    System.out.println("pathInfo: "+request.getPathInfo());
    System.out.println("Protocollo: "+request.getProtocol());
    System.out.println("RemoteAddr:"+request.getRemoteAddr());
    System.out.println("RemoteHost:"+request.getRemoteHost());
    System.out.println("SessionID:"+request.getRequestedSessionId());
    System.out.println("Schema:"+request.getScheme());
    System.out.println("SeesionValido:"+String.valueOf(request.isRequestedSessionIdValid()));
    System.out.println("FromURL:"+String.valueOf(request.isRequestedSessionIdFromURL()));
    int i = request.getContentLength();
    System.out.println("i: "+i);
    ritornaFile(servletinputstream, "C:"+File.separator+"Pluto.tif");
    System.out.println("GetMimeType= "+getServletContext().getMimeType("Ms.tif"));
    InputStream is = request.getInputStream();
    int in = is.available();
    System.out.println("Legge dallo stream in="+in);
    DataInputStream diss = new DataInputStream(servletinputstream);
    int ins = diss.read();
    System.out.println("Legge dallo stream ins="+ins);
    int disins = diss.available();
    System.out.println("Legge dallo stream disins="+disins);
    is.close();
    System.out.println("Fine Servlet");
    catch(Exception exception) {
    System.out.println("IOException occured in the Server: " + exception.getMessage());exception.printStackTrace();
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    public void ritornaFile(InputStream its, String fileDest )throws Exception{
    FileOutputStream f = null;
    try{
    f = new FileOutputStream(fileDest);
    byte[] buf = new byte[2 * 1024];
    int byteLetti;
    while((byteLetti = its.read()) != -1){
    f.write(buf, 0, byteLetti);
    f.flush();
    System.out.println("Byteletti="+byteLetti);
    }catch(Exception ex){
    System.err.println(ex.getMessage());
    }finally{
    if(f != null)f.close();

    Hi all,
    Can anyone help me.I am trying to send an audio file from a applet to servlet with HTTP method(no raw sockets), also the servlet shld be able to save the file on the server.Any suggestions welcome.USing audiostream class from javax.sound.sampled.
    The part of applet code which calls servlet is :
    URL url = new URL("http://" + host + "/" + context + "/servlet/UserUpdateWorkLogAudio?userid=" + userId.replace(' ', '+') + "&FileName=" + filename.replace(' ', '+'));
    URLConnection myConnection = url.openConnection();
    myConnection.setUseCaches(false);
    myConnection.setDoOutput(true);
    urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
    myConnection.connect();
    out = new BufferedOutputStream(myConnection.getOutputStream());
    AudioSystem.write(audioInputStream, fileType,out); // IS THIS RIGHT APPROACH?
    ************************end of applet code**********************
    ************************servlet code******************************
    try
    {BufferedInputStream in = new BufferedInputStream(request.getInputStream());
    ????????What code shld i write here to get the audio file stream
    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(filename));
    *********************************************end***********************
    Thanks
    Joe.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to update content of a file on server using a Java Applet?

    Hi,
    I'm new to Java, and I have a task now to overwrite a text file on a server using an applet. I have written a piece of code which compiles but doesn't work. Can you please take a look at the code or give me another way to do it?
    Thanks.
    Code:
    import java.applet.Applet;
    import java.io.*;
    import java.net.*;
    public class test2 extends Applet{
    public void init() {
    StringBuffer buf = new StringBuffer();
    try {
         String output = "this is some string";
         URL aUrl = new URL (getCodeBase().toString() + "test.txt");
         System.out.println(aUrl);
         URLConnection con = aUrl.openConnection();
         con.setDoOutput(true);
         PrintWriter out = new PrintWriter( new BufferedWriter( new OutputStreamWriter(con.getOutputStream())));
         out.println(output);
         out.close();
    catch (MalformedURLException mue) {
         System.out.println("improper url");
         mue.printStackTrace();
    catch (IOException e) {
         System.out.println("io exception");
         e.printStackTrace();
    }

    Ram.ViSolve wrote:
    869975 wrote:
    Thanks. I knew there would be a security issue, but I do not have sufficient knowledge to get around it. If you have a reference how to configure a server please post it here.You need to create Signed Applet. Because normally applets have some restriction to access the files in the client machine. Signed applets overrides the restriction.
    To know more, Read [url http://192.9.162.55/developer/onlineTraining/Programming/JDCBook/signed.html]Signed Applet
    No. Our OP wants to write to the server, not to the client! And to achieve this from an applet, you don't need it signed, iff the server is the machine from where the applet was downloaded in the first place. You only need to use a mechanism that allows you to write to servers, which HTTP is not. FTP, on the other hand, if setup properly can do it. So instead of trying to write using an HttpURLConnection (OP's attempt), you would use an FTP client library. FTP here is just an example and probably not the best way. Another option is to use some servlet or PHP or ASP on the server side and the applet will sumbmit the changes to that code on the server, which in turn will write to the file. The idea is that you need some 'partner code' on the server, be it the FTP server or the servlet/PHP/ASP code. None of this requires the applet to be signed.

  • Uploading large files from applet to servlet throws out of memory error

    I have a java applet that needs to upload files from a client machine
    to a web server using a servlet. the problem i am having is that in
    the current scheme, files larger than 17-20MB throw an out of memory
    error. is there any way we can get around this problem? i will post
    the client and server side code for reference.
    Client Side Code:
    import java.io.*;
    import java.net.*;
    // this class is a client that enables transfer of files from client
    // to server. This client connects to a servlet running on the server
    // and transmits the file.
    public class fileTransferClient
    private static final String FILENAME_HEADER = "fileName";
    private static final String FILELASTMOD_HEADER = "fileLastMod";
    // this method transfers the prescribed file to the server.
    // if the destination directory is "", it transfers the file to
    "d:\\".
    //11-21-02 Changes : This method now has a new parameter that
    references the item
    //that is being transferred in the import list.
    public static String transferFile(String srcFileName, String
    destFileName,
    String destDir, int itemID)
    if (destDir.equals(""))
    destDir = "E:\\FTP\\incoming\\";
    // get the fully qualified filename and the mere filename.
    String fqfn = srcFileName;
    String fname =
    fqfn.substring(fqfn.lastIndexOf(File.separator)+1);
    try
    //importTable importer = jbInit.getImportTable();
    // create the file to be uploaded and a connection to
    servlet.
    File fileToUpload = new File(fqfn);
    long fileSize = fileToUpload.length();
    // get last mod of this file.
    // The last mod is sent to the servlet as a header.
    long lastMod = fileToUpload.lastModified();
    String strLastMod = String.valueOf(lastMod);
    URL serverURL = new URL(webadminApplet.strServletURL);
    URLConnection serverCon = serverURL.openConnection();
    // a bunch of connection setup related things.
    serverCon.setDoInput(true);
    serverCon.setDoOutput(true);
    // Don't use a cached version of URL connection.
    serverCon.setUseCaches (false);
    serverCon.setDefaultUseCaches (false);
    // set headers and their values.
    serverCon.setRequestProperty("Content-Type",
    "application/octet-stream");
    serverCon.setRequestProperty("Content-Length",
    Long.toString(fileToUpload.length()));
    serverCon.setRequestProperty(FILENAME_HEADER, destDir +
    destFileName);
    serverCon.setRequestProperty(FILELASTMOD_HEADER, strLastMod);
    if (webadminApplet.DEBUG) System.out.println("Connection with
    FTP server established");
    // create file stream and write stream to write file data.
    FileInputStream fis = new FileInputStream(fileToUpload);
    OutputStream os = serverCon.getOutputStream();
    try
    // transfer the file in 4K chunks.
    byte[] buffer = new byte[4096];
    long byteCnt = 0;
    //long percent = 0;
    int newPercent = 0;
    int oldPercent = 0;
    while (true)
    int bytes = fis.read(buffer);
    byteCnt += bytes;
    //11-21-02 :
    //If itemID is greater than -1 this is an import file
    transfer
    //otherwise this is a header graphic file transfer.
    if (itemID > -1)
    newPercent = (int) ((double) byteCnt/ (double)
    fileSize * 100.0);
    int diff = newPercent - oldPercent;
    if (newPercent == 0 || diff >= 20)
    oldPercent = newPercent;
    jbInit.getImportTable().displayFileTransferStatus
    (itemID,
    newPercent);
    if (bytes < 0) break;
    os.write(buffer, 0, bytes);
    os.flush();
    if (webadminApplet.DEBUG) System.out.println("No of bytes
    sent: " + byteCnt);
    finally
    // close related streams.
    os.close();
    fis.close();
    if (webadminApplet.DEBUG) System.out.println("File
    Transmission complete");
    // find out what the servlet has got to say in response.
    BufferedReader reader = new BufferedReader(
    new
    InputStreamReader(serverCon.getInputStream()));
    try
    String line;
    while ((line = reader.readLine()) != null)
    if (webadminApplet.DEBUG) System.out.println(line);
    finally
    // close the reader stream from servlet.
    reader.close();
    } // end of the big try block.
    catch (Exception e)
    System.out.println("Exception during file transfer:\n" + e);
    e.printStackTrace();
    return("FTP failed. See Java Console for Errors.");
    } // end of catch block.
    return("File: " + fname + " successfully transferred.");
    } // end of method transferFile().
    } // end of class fileTransferClient
    Server side code:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.net.*;
    // This servlet class acts as an FTP server to enable transfer of
    files
    // from client side.
    public class FtpServerServlet extends HttpServlet
    String ftpDir = "D:\\pub\\FTP\\";
    private static final String FILENAME_HEADER = "fileName";
    private static final String FILELASTMOD_HEADER = "fileLastMod";
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException,
    IOException
    doPost(req, resp);
    public void doPost(HttpServletRequest req, HttpServletResponse
    resp)
    throws ServletException,
    IOException
    // ### for now enable overwrite by default.
    boolean overwrite = true;
    // get the fileName for this transmission.
    String fileName = req.getHeader(FILENAME_HEADER);
    // also get the last mod of this file.
    String strLastMod = req.getHeader(FILELASTMOD_HEADER);
    String message = "Filename: " + fileName + " saved
    successfully.";
    int status = HttpServletResponse.SC_OK;
    System.out.println("fileName from client: " + fileName);
    // if filename is not specified, complain.
    if (fileName == null)
    message = "Filename not specified";
    status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    else
    // open the file stream for the file about to be transferred.
    File uploadedFile = new File(fileName);
    // check if file already exists - and overwrite if necessary.
    if (uploadedFile.exists())
    if (overwrite)
    // delete the file.
    uploadedFile.delete();
    // ensure the directory is writable - and a new file may be
    created.
    if (!uploadedFile.createNewFile())
    message = "Unable to create file on server. FTP failed.";
    status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    else
    // get the necessary streams for file creation.
    FileOutputStream fos = new FileOutputStream(uploadedFile);
    InputStream is = req.getInputStream();
    try
    // create a buffer. 4K!
    byte[] buffer = new byte[4096];
    // read from input stream and write to file stream.
    int byteCnt = 0;
    while (true)
    int bytes = is.read(buffer);
    if (bytes < 0) break;
    byteCnt += bytes;
    // System.out.println(buffer);
    fos.write(buffer, 0, bytes);
    // flush the stream.
    fos.flush();
    } // end of try block.
    finally
    is.close();
    fos.close();
    // set last mod date for this file.
    uploadedFile.setLastModified((new
    Long(strLastMod)).longValue());
    } // end of finally block.
    } // end - the new file may be created on server.
    } // end - we have a valid filename.
    // set response headers.
    resp.setContentType("text/plain");
    resp.setStatus(status);
    if (status != HttpServletResponse.SC_OK)
    getServletContext().log("ERROR: " + message);
    // get output stream.
    PrintWriter out = resp.getWriter();
    out.println(message);
    } // end of doPost().
    } // end of class FtpServerServlet

    OK - the problem you describe is definitely what's giving you grief.
    The workaround is to use a socket connection and send your own request headers, with the content length filled in. You may have to multi-part mime encode the stream on its way out as well (I'm not about that...).
    You can use the following:
    http://porsche.cis.udel.edu:8080/cis479/lectures/slides-04/slide-02.html
    on your server to get a feel for the format that the request headers need to take.
    - Kevin
    I get the out of Memory Error on the client side. I
    was told that this might be a bug in the URLConnection
    class implementation that basically it wont know the
    content length until all the data has been written to
    the output stream, so it uses an in memory buffer to
    store the data which basically causes memory issues..
    do you think there might be a workaround of any kind..
    or maybe a way that the buffer might be flushed after
    a certain size of file has been uploaded.. ?? do you
    have any ideas?

  • Problem while sending seriailized  object from applet to servlet

    Hi I m having Object communication between Applet and Servlet.
    I m getting error stack trace as
    java.io.EOFException
         at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
         at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
    at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
         at java.io.ObjectInputStream.<init>(Unknown Source)
         at com.chat.client.ObjectClient.write(ObjectClient.java:56)
    at the line
    ObjectInputStream ois = new ObjectInputStream(conn.getInputStream());
    thanks in advance
    Ravi
    the whole code is as follows....
    public Serializable write(Serializable obj) throws IOException,ClassNotFoundException{
              URLConnection conn = serverURL.openConnection();
              conn.setDoOutput(true);
              conn.setDoInput(true);
              conn.setUseCaches(false);
              conn.setRequestProperty("Content-Type", "java-internal/"+obj.getClass().getName());
              conn.connect();
              ObjectOutputStream oos= null;
              try{
              oos = new ObjectOutputStream(
                   conn.getOutputStream());
                        oos.writeObject(obj);
                   catch(Exception ee){
                                       ee.printStackTrace();
                   finally{
                        if(oos!=null){
                             oos.flush();
                             oos.close();
                        return the reponse to the client
                   ObjectInputStream ois=null;
                   try{
    \\this is the line where i m getting the error               
    ois = new ObjectInputStream(conn.getInputStream());
                             return (Serializable)ois.readObject();
                        catch(Exception ee){
                                            System.out.println("Error in Object Client inputstream ");
                                            ee.printStackTrace();
                                            return null;
                        finally{
                             if(ois!=null){
                                  ois.close();

    Did anyone find a fix to this problem. I am having a similiar problem. Sometimes I receive an EOFException and othertimes I don't. When I do receive an EOFException I check for available() in the stream and it appears 0 bytes were sent to the Servlet from the Applet.
    I am always open to produce this problem when I use File->New in IE my applet loads on the new page.. and then I navigate to a JSP sitting on the same application server. When I go to the Applet on the initial page and try to send an object to the server I get an EOFException. No idea!

  • Java applet security file.list()

    I am trying to read the directory structure from a signed applet. I
    have created the applet and provided it with the
    UniversalFileAccess. I am able to read a specific file, and see all
    the contents of the file. I am wanting to performa simple
    directory listing vie the following code.
    My browser is Communictor 4.76 on Win 2000.
    blah.. blah...
    if(browser.indexOf("netscape") >= 0){
    //Assert Netscape permissions
    try{
    // tried UniversalFileRead, UniversalFileAccess,
    UniversalPropertyWrite,
    PrivilegeManager.enablePrivilege("UniversalFileRead");
    System.out.println("Netscape now has UniversalFileRead
    privilege.");
    } catch (netscape.security.ForbiddenTargetException e1) {
    System.out.println("Permission to read file system denied by
    user.");
    e1.printStackTrace();
    } catch(Throwable e){
    System.out.println("Could not enable privilege." +
    e.getMessage());
    e.printStackTrace();
    try {
    File f = new File("c:\\temp\\");
    String [] fileList = a.list();
    } catch (Throwable e) {
    System.out.println("File List failed");
    e.printStackTrace();
    I keep getting a secuity exception that I do not have priveledes to
    perform this action.
    Can anyone help!!!!!!!! I am on a deadline, and this is working just
    fine with IE.
    Please reply directly to me, as this is the first time I've ever posted
    to this newsgroup. My email is [email protected]
    Thanks,
    James Kurfees

    This question has been asked many times in these forums.
    There is no way to prevent this from a determined reverse engineer.
    Search for java obfuscators, which can help a little bit.
    The only way to prevent code stealing is to run it on your own server,
    which means not to use applets, but servlets/JSP. I am sure this is
    not what you want to hear.

  • Newbie: Is the CMS output HTML or Java applets?

    Hi!
    I am looking for what software to buy: Microsoft or Oracle.
    In that regard, I see that Java is the development language. Does this mean that the web-interface for clients is based on Java applets, or does the Java-application just generate HTML-code like asp.NET, php and similar server-side languages?
    Thanks!

    The old Oracle 9iFS web interface was based on Java and JSP, and as such, was an HTML-based interface. It did not use applets.
    The new Oracle CMSDK will include a web starter application sample (with source code) also based on Java and JSP, which is also an HTML-based interface that does not use applets.
    The CMSDK is a development platform, and you could write a web interface based on Java applets if you wanted to, or based on HTML technologies such as servlets (J2EE) or JSP. You can also write standalone client software in any language that communicates with the CMSDK server using a protocol, such as HTTP. You may define your own protocol and write your own protocol server (in Java), or you may use an existing protocol, like WebDAV/HTTP.
    See the CMSDK developer's guide for more information.

  • Greek lettets and java applet???

    Hello,
    I'm using Linux and i have a problem with the greek letters on the java applets on web pages....
    instead of greek letters i see little squares...
    i don't have much experience nor with linux neither with java.........
    (Sorry for my bad english)
    can u help me please?

    Are you using a browser on the Linux box and it can not display the Greek letters in the applets?
    Or is the Linux box running a servlet engine and is there a problem with the HTML pages and the applets coming from it?
    Edited by: BIJ001 on Sep 27, 2007 10:43 AM

  • Embed java applet in web dynpro

    Hi experts,
    is it possible to embed a java applet into a web Dynpro application. Or have I to use a jsp / Servlet / AbstractPortalApplication / (JSP)Dynpage
    Regards
    Fllo

    Hi
    yes its possible...
    go thorugh these docs..:[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/91b8c890-0201-0010-c787-be96f6fade89]
    [http://www.vogella.de/articles/SAPWebDynpro/article.html]
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8382535d-0d01-0010-dbb5-d3d41dfefd10]
    hpe it hlps u..
    Regards,
    Khushboo

  • About connecting applets to servlets

    Hi friens,
    I already posted regarding this problem twice but there were no replies. i am really desperate as it is eating up my time. I thought once more i will elaborate it.
    I am using the following code to connect an applet to servlet on my tomcat.
    /////////// swing code ////////////
    URL url = new URL(getCodeBase() + "MasterServlet?handlerName=SendGraphData&sessionid="+sessionid);
    URLConnection con = url.openConnection();
    con.setUseCaches(false);
    con.setDoOutput(true);
    con.setRequestProperty ("Content-Type", "application/octet-stream");
    ObjectOutputStream obj;
    obj = new ObjectOutputStream(con.getOutputStream());
    obj.writeObject(selectedNodes);
    obj.writeObject(saveType);
    obj.flush();
    obj.close();
    If i just use the connection to receive objects from servlet it is working fine. But if i use the statement "con.getOutputStream()" in the above code, connection is not getting established with the servlet at all (it is not going into the servlet). But some times it does go into the servlet but throws "java.io.EOFException" at the statment "request.getInputStream()" , which i call in my servlet code to read the objects sent by the applet.
    i already wasted one week on this. so, pls try to bail me out.
    bye
    steve

    Here is what I have. I did not use ObjectOutputStream as you did, however - just XML. I hope this is useful...
    url = new URL(sTheURL);
    con = url.openConnection();
    con.setRequestProperty("Content-Type", " application/x-www-form-urlencoded");
    con.setDoInput(true);
    con.setDoOutput(true);
    con.setUseCaches(false);
    con.setDefaultUseCaches(false);
    sXML = URLEncoder.encode(sXML);
    sXML = XML + "=" + sXML;
    OutputStream out = con.getOutputStream();
    out.write(sXML.getBytes());
    out.flush();
    out.close();
    InputStream is = con.getInputStream();
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    String line=null;
    while( (line = br.readLine())!=null)
         respBuf.append(line);
    br.close();

  • Probem with applet and servlets

    subject "not able to invoke applet from servlets"
    i have attached files also..
    Respected sir,
    I am thomas from prateek techologies ,referred by madam Pratibha.
    Actually i have to plot point marks on a image(it is a Banglore map) in an applet(Uploadimg3.java).so, for doing so, iam getting values from database in my servlet file named Mapuser_sev.java
    which is in the directory
    WEB-INF/classes.
    now after fetching the values ,i am not able invoke the Applet (Uploadimg3.java)which is in the directory
    WEB-INF/classes/mapuser.
    i have used the api ,response.sendredirect("/prakash/jspfiles/displaymap1.jsp");-->up to here it's ok..
    I have used the plugin tag as follows:-
    displaymap1.jsp
    <html>
    <body>
    <jsp:plugin type="applet" code="Uploadimg3.class" codebase="WEB-INF/classes/mapuser" width="400" height="400">
    </jsp:plugin>
    </body>
    </html>
    if the plugin tag is wrong then please send me the correct coding for "jsp: plugin" with explaination.
    this is my directory hierarchy..
    jspfiles-->directory(folder)
    Prakash/jspfiles/displaymap1.jsp ----->this file has the plugin tags as mentioned above..
    Prakash is my context..
    WEB-INF/
    classes/Mapuser_serv.class -----> this is a servlet file
    mapuser/
    Uploadimg3.java -----> this is a Applet file
    Uploadimg3.class
    Mapuser1.java ---> i used this file to fetchdata from db ,please forget this file ..
    Mapuser1.class
    with regards,
    Thomas..

    It might be the restrictions java has about opening files in a web browser. I don' t know if it's allowed or not..

  • Calling an applet from servlet

    Hi
    I'm devoloping a server side java software(on netbeans 6) and I want my gui classes(Designed as swing japplet application) to be executed on server side.
    I mean I have database operations on my applet and some logging functions and I want them to execute on server side not client side
    Is it possible to call applets from servlet and so its executed on server if it is possible how can i do that is there a tutorial for that ?
    If it is not is there any other solution? Its really urgent for me
    Thanks

    tolgatanriverdi wrote:
    I'm devoloping a server side java software(on netbeans 6) and I want my gui classes(Designed as swing japplet application) to be executed on server side.Call a company named Citrix, they do stuff like that using a special client.
    I mean I have database operations on my applet and some logging functions and I want them to execute on server side not client sideSo it's not the GUI classes but the rest of the business logic.
    Is it possible to call applets from servlet and so its executed on server if it is possible how can i do that is there a tutorial for that ?It's possible for a servlet to call any class. It's not easily possible for a servlet to connect to a certain applet instance running on a certain client, and neither should it. Hello - it's the server. It's supposed to answer to requests. It's not supposed to issue requests to the client. And considering your set-up as I understood it, you don't ned that anyway. Let the applet just tell the servlet to do action X or Y or Z.
    Its really urgent for meGood Thing that you wrote it here. If you had written it at the beginning of your post, I wouldn't have bothered to answer.

Maybe you are looking for

  • Preview and highlighting

    Just recently whenever I use Preview and annotate my documents I get this weird triangular shade on the word I highlighted instead of the usual blocked look. How do I change this back?? Here is how it looks: http://i248.photobucket.com/albums/gg175/m

  • MacBook Pro won't work

    My MacBook Pro when turned on a green/black screen appears then the normal apple screen loads. Then another pixelated screen loads and a shutdown icon appears. What's happened?

  • Flash issue in Safari Browser

    I've created a simulation in Flash 8. The simulation is working fine in IE7 but when I'm launching the sim in Safari browser the sim is not working as it should. I'm getting some issues like: Some SWFs are not getting loaded. Some Functions are not w

  • How to deploy an WCF OData Service in windows azure

    I am having a WCF OData service in visual studio which i need to deploy in windows azure for accessing in IPad app. thanks in advance

  • Long LOV for editable column

    I have an updateable report based on a SQL Query with a few columns in it. One of the columns is an id referencing another table (a foreign key). I would like to display a descriptive name from the referenced table along with the id and provide a LOV