Give me a hand please!!

I have applet running in my webpage, and I'd like to keep track of how often it downloads by client user and how long s/he runs it. it is possible for applet to write in a file at the server and how. how can implement this function?

Hi almahd,
Although I haven't done anything like this -- and I haven't got time to try it out myself -- I can see two possibilities.
1. You can execute a CGI script or servlet on the web-server (that downloads your applet) each time the applet is downloaded. If I'm not mistaken, then the best place to call the CGI/servlet would be from the applet's "init()" method. An example of how to execute a CGI script fro a java class can be found here:
http://www.javaworld.com/javaworld/jw-03-2001/jw-0323-traps.html
2. Since an applet can communicate with the web-server that downloaded it, you should be able to simply update a file located on the server. You would have to use that file's URL to locate it (I would imagine). I don't really know what sort of URL is required, though.
Hope this has helped you (for what it's worth :-)
Good Luck,
Avi.

Similar Messages

  • Exception when readObj() - please give me a hand!

    I am writing a Client/Server application where Server simply sends object to the client. The first object goes well but when the client side reads the second object, the exception caught was "Type code out of range, is -84". Can anybody kindly give me a hand? Thanks very much in advance!
    Result on Client:
    C:\thesisTest>java TestCli
    @Line 1: Get ready!!!
    Type code out of range, is -84
    receive error.
    Source for Server :
    import java.net.*;
    import java.io.*;
    import java.util.*;
    import sendNode;
    public class TestSer {
         static sendNode sendNodeObj = new sendNode();
    static String inputLine;
         public static void main(String[] args) throws IOException {
    ServerSocket serverSocket = null;
    try {
    serverSocket = new ServerSocket(4444);
    } catch (IOException e) {
    System.err.println("Could not listen on port: 4444.");
    System.exit(1);
    Socket clientSocket = null;
    try {
    clientSocket = serverSocket.accept();
    } catch (IOException e) {
    System.err.println("Accept failed.");
    System.exit(1);
    OutputStream o = clientSocket.getOutputStream();
    ObjectOutput out=new ObjectOutputStream(o);
    BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        clientSocket.getInputStream()));
    sendNodeObj.sendMsg="@Line 1: Get ready!!!";
    sendNodeObj.typeNode=-1;
    out.writeObject(sendNodeObj);
    out.flush();
    out=new ObjectOutputStream(o);
    sendNodeObj.sendMsg="@Line 2: Please input Start";
    sendNodeObj.typeNode=-1;
    out.writeObject(sendNodeObj);
    out.flush();
    inputLine = in.readLine();
    while (!inputLine.equalsIgnoreCase("Start")) {
         sendNodeObj.sendMsg="@Error, Please input Start";
    sendNodeObj.typeNode=-1;
    out.writeObject(sendNodeObj);
    out.flush();
    inputLine = in.readLine();
    out.close();
    in.close();
    clientSocket.close();
    serverSocket.close();
    Source for Client:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.applet.Applet;
    import sendNode;
    public class TestCli extends Applet {
    static sendNode recNodeObj=null;
    public static void main(String[] args) throws IOException {
    BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
    Socket kkSocket = null;
    PrintWriter out = null;
    try {
    kkSocket = new Socket("127.0.0.1", 4444);
    out = new PrintWriter(kkSocket.getOutputStream(), true);
    } catch (UnknownHostException e) {
    System.err.println("Don't know about host.");
    System.exit(1);
    } catch (IOException e) {
    System.err.println("Couldn't get I/O for the connection to: taranis.");
    System.exit(1);
    InputStream i= kkSocket.getInputStream();
    ObjectInput in= new ObjectInputStream(i);
    try {
         recNodeObj = (sendNode)in.readObject();
    System.out.println(recNodeObj.sendMsg);
         recNodeObj = (sendNode)in.readObject();
    System.out.println(recNodeObj.sendMsg);
    if (recNodeObj.sendMsg.equalsIgnoreCase("@Line 2: Please input Start")) {
    out.println("Start");
    } catch (Exception e) {
    System.out.println(e.getMessage());
    System.out.println("receive error.");
    System.exit(1);
    out.close();
    in.close();
    stdIn.close();
    kkSocket.close();

    You are not being consistent in the way you use ObjectOutputStream and ObjectInputStream.
    For every new ObjectOutputStream you create you need a corresponding new ObjectInputStream, because ObjectOutputStream writes a header that ObjectInputStream reads.
    In general, you probably don't want to use multiple OutputOutputStream objects on a given underlying socket, because it is ineffecient in the way class names etc are encoded.
    Sylvia.

  • When I try to start my macbook it gives an error of Please restart your computer, but when i do this i get the same error.

    When I try to start my macbook it gives an error of Please restart your computer, but when i do this i get the same error. This occured after my macbook pro shut down (because of low battery) while it was installing some updates. Please Help?

    Try reinstalling OS X. What version did you have installed? If it's Snow Leopard do this:
    Reinstall OS X without erasing the drive
    Do the following:
    1. Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    2. Reinstall Snow Leopard
    If the drive is OK then quit DU and return to the installer.  Proceed with reinstalling OS X.  Note that the Snow Leopard installer will not erase your drive or disturb your files.  After installing a fresh copy of OS X the installer will move your Home folder, third-party applications, support items, and network preferences into the newly installed system.
    Download and install the Combo Updater for the version you prefer from support.apple.com/downloads/.

  • I am having problems opening images renerated in lightroom5 into cs6. Cs6 bridge does not see the lightroom libarary. If I open lightroom and right clik the image, edit in cs6, 6 opens but the picture doesnot follow. What is going on? Give me a hand.

    I am having problems opening images renerated in lightroom5 into cs6. Cs6 bridge does not see the lightroom libarary. If I open lightroom and right clik the image, edit in cs6, 6 opens but the picture doesnot follow. What is going on? Give me a hand, thanks.

    What edition of LR 5? What edition of ACR does PSCS 6 contain. If they are not parallel (same edition number x in [5 or 8].x ), is LR making a tiff or psd rendition of the image?

  • How to calculate the number of vowels from a txt file. Pls give me a hand!!

    Guys! How do i calculate the number of vowels from a txt file? I have to create a program to count the number of words, sentence, and vowels. So far I had managed to count the number of words. Now I need help on counting sentence and vowels! Pls give me a hand guys!

    I first have to read from the file not the string.I
    know how to read from a file. Now the problem ishow
    to compare a character from a txt file!You fail to understand, that you have read the data
    from the file into a string. Now loop over all
    characters in the string. Forget about the file.
    KajOr forget the scanners just as others have told you. Just read the file character by character using a FileReader.
    Kaj

  • Hi I,m Wonkeun Kim. Could u give me a hand to solve the problem which now i forget answers of my security questions. How should i do to reset my answers??

    Hi I,m Wonkeun Kim. Could u give me a hand to solve the problem which now i forget answers of my security questions. How should i do to reset my answers??

    Forgotten Security Questions / Answers...
    See Here > Apple ID: Contacting Apple for help with Apple ID account security
              Ask to speak with the Account Security Team...
    Or Email Here  >  Apple  Support  iTunes Store  Contact
    More Info >  Apple ID: All about Apple ID security questions
    Note:
    You can only set up and/or change a Rescue Email Before you forget the questions/answers.

  • Ibook g4 late hardrdware test or fresh installation, strange thing is will accept every item on disk 1 accept clean installation or hardware test, give me a clue please, thanks robin u/k.

    Have a iBook G4 14' 142 ghz early 2006 owned since new, have had no problems in the past to do a clean installation or a hardware test. Find I cannot do these now, strange that I can do all other checks, tests etc on Disk one but not the ones I have listed, Strange, give me a clue please, Robin U/K.

    This iBook came originally with Mac OSX 10.4.2 or 10.4.4 installed and on the disks. Since you have upgraded to 10.5.8 I am guessing there is some kind of reluctance for a retrograde OS installation. I would start up from disk 1 and under utilities see if Disk Utility will allow you to erase or re partition the drive. Then do the 10.4.x installation. First be sure to backup any data of value.

  • HT201210 i cannot get my phone out of recovery mode, when I tried to restore on itune it gives me error 1608. please help me

    i cannot get my phone out of recovery mode, when I tried to restore on itune it gives me error 1608. please help me

    While YOU may not have attempted to jailbreak the phone, SOMEONE ELSE did.  Error 1015 occurs by attempting to restore a previously jailbroken phone. 
    It's very likely you may NEVER get your phone out of recovery mode and your phone may be rendered permanently bricked.
    Terms of Use of this forum prohibit the discussion of jailbroken phones.  You'll have to scour the internet for a solution to your problem, if indeed one exists.

  • Hi, someone please help me out... am Nelson and got an issue with my apple Qmaster... I got OSX maverix and on my system preferences the Apple Qmaster dosent load but only gives an error, someone please help.

    hi, someone please help me out... am Nelson and got an issue with my apple Qmaster... I got OSX maverix and on my system preferences the Apple Qmaster dosent load but only gives an error, someone please help.

    the error is like "Could not load Apple Qmaster preference pane"
    if there is a way around it please help me coz I cannot render my video projects on Compressor anymore...

  • HT201210 I have a iPhone 3 g, I'm doing update and give me error 1015 Please help and thank you

    I have a iPhone 3 g, I'm doing update and give me error 1015 Please help and thank you

    You can not get help here per the terms of service. Discussing jailbroken devices is forbidden.
    The ONLY thing we can advise you to do is try putting the phone in DFU mode (google for instructions) and restore it.
    Beyond that, you're on your own.

  • Can anyone give me a hand with Quicktime?

    I used to be able to watch movies and video on fullscreen mode or the Present Movie mode with noproblems at all. Now, everytime I try to set it up nothing happens, it's like the window goes into ghost mode... any ideas will be very welcome.

    Is it possible that anyone doesn´t want to give me a hand?

  • Novice asking qn, pls give a helping hand

    i am trying to develop a distributed system that needs password checking in order to access.
    Hence i need to check user password in my database that resides in my server.
    so when ReMoTe user click "enter" after typing password.. how do i connect to my server database to verify?? is my solution given below the norm?
    suggested solution: pass the userID and password to the server using HttpServletRequest, from there, the server listen for request and process connecting to local DB if a request is detected..
    am i correct... pls give a helping hand...

    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class LoginServlet extends HttpServlet{
         private Connection con;
         private PreparedStatement pstmt;
         private Statement stmt;
         private ResultSet rs;
         private String pass = "";
         private String login="",password="",done="";
         private HttpSession session;
         public void doPost(HttpServletRequest request,HttpServletResponse response)
         throws ServletException, IOException{
              login = ""+request.getParameter("login");
              password = ""+request.getParameter("password");
              done = ""+request.getParameter("done");
              session = request.getSession(true);
              PrintWriter out = response.getWriter();
              out.println(login);
                        out.println(password);
              try{
                   Class.forName("org.gjt.mm.mysql.Driver");
              }catch(Exception e){
                   out.println(e.getMessage());
              try{
                   con = DriverManager.getConnection("jdbc:mysql:///senji");
                   if(!(password.equals("")&&login.equals(""))){
                        pstmt = con.prepareStatement("select password from logon where login = ?");
                        pstmt.setString(1,login);
                        rs = pstmt.executeQuery();
                        pass = "";
                        while(rs.next()){
                             pass = rs.getString(1);
                        if(pass.equals(password)){
                             session.setAttribute("login",login);
                             if(done.equals("null")){
                                  done = "";
                                  pass = "";
                                  response.sendRedirect("/ksenji/quiz2/shoponline.jsp");
                             }else{
                                  response.sendRedirect(done.substring(5));
                        else{
                             response.sendRedirect("/ksenji/quiz2/login.jsp?"+done);
                   else{
                        response.sendRedirect("/ksenji/quiz2/login.jsp?"+done);
              }catch(SQLException ex){
                   out.println(ex.getMessage());
    }

  • Please Give Me Your Hands

    Here is my codes, I try to save the "drawing" Panel graphics into a jpg, and I can compile it, however, when I run it, system tell me" NullPointerException"!!!
    I'm out of ideas, Please help, Thank you So much!!!
    import java.awt.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.imageio.*;
    import com.sun.image.codec.jpeg.*;
    import java.io.*;
    import java.awt.geom.*;
    public class test3 extends JFrame
         public test3()
              super("test");
              setSize(800, 600);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              drawingArea drawing = new drawingArea();
              Container c = getContentPane();
              c.add(drawing, BorderLayout.CENTER);
              int paneWidth = drawing.getWidth();
              int paneHeight = drawing.getHeight();
              BufferedImage buffer = new BufferedImage(600, 600, BufferedImage.TYPE_INT_RGB);
              buffer = (BufferedImage)drawing.createImage(paneWidth, paneHeight);
              Graphics graphic = buffer.getGraphics();
              if(graphic.getClipBounds()!=null)
                   graphic.setClip(0, 0, paneWidth, paneHeight);
              drawing.paint(graphic);
              try
                   File file = new File("test.jpg");
                   FileOutputStream out = new FileOutputStream(file);
                   JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                   JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(buffer);
              encoder.setJPEGEncodeParam(param);
              param.setQuality(1.0f,false);
                   encoder.encode(buffer);
                   out.flush();
                   out.close();
              catch(IOException ioe)
                   System.out.println(ioe.toString() + "something wrong");
              catch(RasterFormatException rfe)
                   System.out.println(rfe.toString() + "rfe");
              setVisible(true);
         class drawingArea extends JPanel
              public void paintComponent(Graphics g)
                   Graphics2D g2D = (Graphics2D)g;
                   Rectangle2D.Float rect = new Rectangle2D.Float(50F, 50F, 20F, 20F);
                   g2D.draw(rect);
         public static void main(String args[])
              test3 t = new test3();
    }

    1 - the graphics context of a Component is null until the Component is realized, ie, until you call pack or setVisible on its top-level Container
    2 - you can make up a BufferedImage and save it without using a Component to show it
    3 - using a 'png' extension seems to give better results and a smaller file size than 'jpg'
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    public class ImageTest
        ImageTestPanel imagePanel;
        ImageTestUtility utility;
        BufferedImage image;
        public ImageTest()
            createImage();
            imagePanel = new ImageTestPanel();
            utility = new ImageTestUtility();
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(getUIPanel(), "North");
            f.getContentPane().add(imagePanel);
            f.setSize(400,400);
            f.setLocation(200,200);
            System.out.println("imagePanel graphics context before visible = " +
                                imagePanel.getGraphics());
            f.setVisible(true);
            System.out.println("imagePanel graphics context after realized = " +
                                imagePanel.getGraphics());
        private void createImage()
            int w = 200;
            int h = 200;
            image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = image.createGraphics();
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(Color.white);
            g2.fillRect(0, 0, w, h);
            g2.setPaint(Color.blue);
            g2.draw(new Rectangle2D.Double(w/16, h/16, w*7/8, h*7/8));
            int dia = Math.min(w, h)/4;
            g2.setPaint(Color.red);
            g2.draw(new Ellipse2D.Double(w/2 - dia/2, h/2 - dia/2, dia, dia));
            g2.setPaint(Color.green.darker());
            g2.draw(new Line2D.Double(w/16, h*15/16, w*15/16, h/16));
            g2.dispose();
        private JPanel getUIPanel()
            final JButton
                saveComponent = new JButton("save component"),
                saveImage = new JButton("save image");
            ActionListener l = new ActionListener()
                public void actionPerformed(ActionEvent e)
                    JButton button = (JButton)e.getSource();
                    if(button == saveComponent)
                        utility.saveComponent(imagePanel);
                    if(button == saveImage)
                        utility.saveToFile(image);
            saveComponent.addActionListener(l);
            saveImage.addActionListener(l);
            JPanel panel = new JPanel();
            panel.add(saveComponent);
            panel.add(saveImage);
            return panel;
        public static void main(String[] args)
           new ImageTest();
    class ImageTestPanel extends JPanel
        public ImageTestPanel() { }
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setPaint(Color.red);
            g2.draw(new Rectangle2D.Float(50, 50, 20, 20));
    class ImageTestUtility
        public BufferedImage loadImage(String fileName)
            BufferedImage image = null;
            try
                URL url = getClass().getResource(fileName);
                image = ImageIO.read(url);
            catch(MalformedURLException mue)
                System.err.println("url: " + mue.getMessage());
            catch(IOException ioe)
                System.err.println("read: " + ioe.getMessage());
            return image;
        public void saveComponent(Component c)
            int w = c.getWidth();
            int h = c.getHeight();
            BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2 = bi.createGraphics();
            c.paint(g2);
            g2.dispose();
            saveToFile(bi);
        public void saveToFile(BufferedImage image)
            try
                ImageIO.write(image, "jpg", new File("imageTest.jpg"));
            catch(IOException ioe)
                System.err.println("write: " + ioe.getMessage());
    }

  • Please give me a hand!!!

    please help me!
    HttpServletRequest request;
    i use "request.setAttribute("value",value);" in a method of "Action" to save the value and use "request.getAttribute("value");" to get the value in "jsp" which findForward from the method, but there are two servers being used which are deployed same. my problem is that when the servers are changing randomly to serve you, can i get the value correctly everytime? if the answer is "no", can you help me solve this problem?
    thank you!
    jjrainbow

    You have two clustered servers, either of which can handle the request?
    As I understand it, once a server receives a request it should handle the entire request. Forwarding to another jsp/servlet is purely an internal transition, and so should not result in changing the server.
    If you can make that assumption, then your request attributes will always be present and correct.
    So I think the answer to your question: "can I get the value correctly every time" is yes. Unless you are doing your own custom clustering which does interfer in the request cycle in which case all bets are off. Most likely though, there is no issue .

  • PLEASE! Give me a hand! Ti4800SE TD8X

    HI!
      I installed this card GeForce 4 Ti 4800..everything works out fine, but one thing that i just cant figure out ishow come this sound problem always happens...ok, as i restart my computer, i play music or video (or having something audio on the background ) and then i click the "Start" sign on the left bottom corner..the sound goes off ( it doesnt only happen on when i am clicking "start" sign, It happens so often when i work around on my computer while have any audios playing) But as i restart computer everything works right again.  :( Im so pissed off that i cant hear the sound when i play CS. I put the old card back it worked as good as before.. ;(
    I've tried to installed VIA 4 in 1 new driver (it didnt help :( )
    Installed Nvidia 43.45(right now) i tried 41.09,its the same no help.
    Update new Bios for VGA ( no help)
    OS:windows XP Pro (SP1)
    Sys:P3 800mhz
    Mainboard: Asus CUV4x
    mem:256mb
    HD: 40GB
    Old card: ATi rage128 (32mb)

    gho,
    You said you were using the new VIA drivers?
    These?-------> VIA Hyperion 4in1 v4.46, released 10 March 2003
    Have you tried previous releases or archived drivers?
    Link to "AGP Explained" found at Anandtech
    Where does it get all that RAM from?
    I mentioned before that AGP allows your graphics card to access your system's main memory, therefore AGP memory is simply dynamically-allocated portions of your system's main memory. Meaning that AGP provides a fast access path to your system memory which is provided by some integrated functions in the chipset which allows the AGP card and the software using AGP to access the same memory addresses. This process allows the graphics hardware to address large texture maps as single data objects. The hardware that provides this support is referred to as the Graphics Address Remapping Table, or GART for short. Below is an illustration of how the data is addressed using the GART:

Maybe you are looking for