Saving to the Server from an Applet

Hi all, I've posted a message similar to this before, but didn't get too far. I need to get an applet to be able to open a new browser window and display a web page containing two images from the applet, and several strings from the applet. I need the user to be able to save the images to their hard drive, and I need to be able to use them in email forms from the web page. I assume I would have to somehow save the images and a text file from the applet to the server. I have sucessfully converted my objects of type Image to .gif files (with help from these forums) now all I need to do is find some way to save them or somehow get them onto the web page. I have looked into using a servlet, and using sockets, with little sucess either way. With sockets I keep getting IOExceptions and it says Connection refused. Here's the code I'm using for sockets.
Socket socket;
try {
     socket = new Socket(getCodeBase().getHost(), 8080);
}catch(UnknownHostException u)
  {socket = null; System.out.println("Socket failed"); }
catch(IOException i)
  {socket = null; System.out.println("IO Failed"); i.printStackTrace(); }I didn't get very far with Servlets, as for some reason I can't find very much help on them on the web. Any help is greatly appreciated.

smg123: Well, I've tried modding my policy file on my local machine, I simply gave All Permissions to the directy that contains the applet on my local machine, with no luck. Not sure about signing the applet, if I understand it correctly it seems like that's a bit overkill making the user accept it and such, when all it really needs to do is server side.
FelipeGaucho: I've looked at the servlet tutorial before, but I'll give it another shot. I can't ditch the applet approach entirely though, there's a ton of work put into the applet already.
JohanUP: I've tried a bunch of different port numbers, all with the same results.
Thanks for the tips guys, keep em coming :)

Similar Messages

  • Viewing HTML page saved  on the server from the browser

    Hi all
    In my application i am having some HTML pages saved on the server. I had given an option to the user to view the HTML page from my application. behind the scene what i am doing is that the view request will get handled by a servlet and from that servlet iam locating the HTML page on the server directory and sending the HTML page to browser by using the Servlet OutputStream. The HTML page is shown on the browser but the attached images are not shown. The images are also there in the server directory and are refered in the HTML file correctly. When i directly open the HTML file then the images are shown correctly.
    Can anyone suggest wat's wrong there.
    The code i m using is
    ServletOutputStream out=response.getOutputStream();
                        if(format.equalsIgnoreCase("pdf"))
                             logger.info("Seleted format is pdf..\n");
                             response.setContentType("application/pdf");
                        else
                             logger.info("Seleted format is html..\n");
                             response.setContentType("text/html");
    String file = ReportingConstants.URL_GENERATEDREPORTS+reportPath+itemName;
    // file : HTML file absolute path as string.
                        URL url=new URL(file);                    
                        BufferedInputStream bis=new BufferedInputStream(url.openStream());
                        BufferedOutputStream bos=new BufferedOutputStream(out);
                        byte[] buff = new byte[2048];
                        int bytesRead;
                        while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
                             bos.write(buff, 0, bytesRead);
                             bos.flush();
                        }

    You have to undertsand how the browser handles images and other resources in a HTML page. In the HTML there is an image tag that has a url to an image which can be a reletive url or an absolute url (starts with a "/").
    If the url is a relative url the browser interprets the url as being relative to the url currently displayed in the address field discarding the last element of the url . So if the url in the address bar is http://www.myserver.com/myapp/mypage.html and the relative url is images/myimage.jpg, the browser will submit a request to the server for http://www.myserver.com/myapp/images/myimage.jpg
    Now let's say that you are call mypage.html from a servlet that has the url http://www.myserver.com/myapp/servlets/myservlet. Then when the browser tries to retrieve myimage.jpg it will use the url http://www.myserver.com/myapp/servlets/myservlet/images/myimage.jpg and since this is incorrect it will not be able to display the images.
    One solution to this is to change all of the image urls to absolute urls. That is the start with a slash where the slash represents the start of the url after the application domain name. For example you used an absolute url for myimage.jpg it would look like /images.myimage.jpg and when accessing the page through the servlet url (http://www.myserver.com/myapp/servlets/myservlet) the browser will discard everything after http://www.myserver.com/myapp and look for the image at http://www.myserver.com/myapp/images/myimage.jpg which is the correct url.
    A second solution is to use the HTML BASE tag which tells the browser not to interpret the image tag urls (and other resourses) using the current url in the address bar but to use the url supplied in the HTML BASE tag. The browser will still perform the same process for relative urls but now relative to the BASE tag url. Since the BASE tag url will be the same every time the page is accesssed the images should be correctly accessed no matter how the page is accessed (eg directly, using RequestDistpatcher or via your servlet)

  • Opening a text file in server from an applet running in the client

    Friends,
    I want to open a text file in the server(The server machine uses tomcat 4.1.12 server)from an applet running in the client machine;
    The applet invokes a servlet that opens the text file;this text file is opened in the server machine; but I want it to be opened in the client machine where the applet is running.
    Plese help me to get around this.

    You can open the textfile on the servlet and then send the information to the client (applet) as stirngs. The must then applet convert the stirngs into some object or simply display the information in someway. But then the text file that you are opening must be stored in some relevant tomcat directory e.g. on the server. If you want to open a file on the clients computer, you get into signed applets.

  • I deleted a message from iCloud mail. It says it is saved on the server for 1 month. Can I get to it?

    I deleted a message from my iCloud mail (and emptied the trash) on my MAC that I didn't mean to. In my iCloud IMAP settings it says that deleted mail will be saved on the server for 1 month. How do I get to it?

    Go to http://www.icloud.com and go to the Mail page there. Open the Trash mailbox. If the message is there you can move it out. If it isn't, then I'm afraid it's gone. The 'delete after x days' setting in the Mail application is over-ridden by the automatic deletion in the iCloud server - I have an idea that's 7 days but I'm not sure.

  • Communicating with server from an Applet.

    Hi, i've written a tetris game in an applet.
    But i want some way of saving the high scores of everyone on the server.
    Is they anyway to communicate the final score back to the server from the applet?
    I tried saving the scores to a text file but apparently the file would appear on the client.

    Here is some code that you may find useful. This works for the more flexible serialized object approach. For a query string, you would simply do a post on the servlet with the appropriate URL that includes the query string. However, I have found the following serialized object approach to be more convenient.
    import java.net.*;
    import java.io.*;
    This function sends an "AppletRequest" object to the servlet and gets the response back from the servlet in the form of a "ServletResponse" object.
    protected static ServletResponse talkToServlet(AppletRequest aReq) {
    ServletResponse sr = new ServletResponse();
    try {
    // Replace the following URL by the URL of your servlet
    servletURL = new URL("http://myservleturl/");
    servletConn = servletURL.openConnection();
    servletConn.setUseCaches (false);
    servletConn.setRequestProperty("Content-Type",
    "application/octet-stream");
    servletConn.setDoInput(true);
    servletConn.setDoOutput(true);
    } catch (MalformedURLException ex) {
    System.out.println("MalformedURLException"+ex.getMessage());
    } catch (IOException ex) {
    System.out.println("IOException"+ex.getMessage());
    } catch (Exception ex) {
    System.out.println ("GeneralException: " + ex.getMessage());
    try {
    outputToServlet = new ObjectOutputStream(servletConn.getOutputStream());
    outputToServlet.writeObject(aReq);
    outputToServlet.flush();
    outputToServlet.close();
    } catch (Exception ex) {
    System.out.println("GeneralException1: "+ex.getMessage());
    try {
    try{
    inputFrServlet = new ObjectInputStream(servletConn.getInputStream());
    sr = (ServletResponse) inputFrServlet.readObject();
    inputFrServlet.close();
    } catch (EOFException ex) {
    System.out.println("EOFException: "+ex.getMessage());
    } catch (IOException e) {
    System.out.println("IOException: "+e.getMessage());
    e.printStackTrace();
    } catch (ClassNotFoundException e) {
    System.out.println("ClassNotFoundException: "+e.getMessage());
    } catch (Exception e) {
    System.out.println("GeneralException2: "+e.getMessage());
    return(sr);

  • The document could not be saved. The server said: "The operation failed because an unexpected error occurred. (Result code 0×80020005)" Please ensure you have completed all required properties with the correct information and try again.

    I am having problems  saving documents back to SharePoint when any of the document properties (metadata columns) are set to be "managed metadata". The check-in/save fails with error:
    The document could not be saved. The server said:
    “The operation failed because an unexpected error occurred. (Result code 0×80020005)”
    Please ensure you have completed all required properties with the correct information and try again.
    I have seen similar threads that suggest this is a known issue with this version of Acrobat but I would like conformation from Adobe that this is a known issue and whether it is fixed in a newer version?
    Adobe Acrobat version 10.1.13
    SharePoint 2010

    Hi quodd,,
    We are sorry for the issue being faced by you. I need some information from you so that I take further steps:
    1. Which Adobe product are you using Acrobat or Adobe reader- what is the complete version?
    2. How are you opening and saving the PDF, the exact workflow?
         Are you doing it from within Adobe Reader/Acrobat application or opening it from browser, doing changes and saving it using browser itself.
    3. Can you try to save a PDF to library with Custom template and managed metadata columns using browser directly.
    4. Please verify that columns name do not contain spaces or some other special characters.
       Can you try to save PDF to library with Custom template and just a single managed metadata column  with a simple name
    Thanks,
    Nikhil Gupta

  • Create a new file on server from an applet

    Hello!
    I 'm trying to create a text file on server from an applet, i have permissions to write on server and i'm running in apache, my code is
    public void write () {
    try{
    URL url = new URL("http://localhost/bnm/hello.txt");
    URLConnection urlcon = url.openConnection();
    urlcon.setDoOutput(true);
    urlcon.setUseCaches(true);
    PrintWriter pt = new PrintWriter
    (new OutputStreamWriter (urlcon.getOutputStream()));
    String str = new String(URLEncoder.encode("this is output applet ")) ;
    pt.print(str);
    pt.flush();
    catch(Exception e)
    e.printStackTrace();
    The result is nothing, the file isn�t created, but the code don't throw exceptions.
    Ah! in other example, i can read a file of server fro m the applet, the problem is to write
    Anybody, knows the matter??
    Excuse my poor english :P
    Thanks for all.

    I had the same needs and didn't know whether this was possible, due to applets security restriction. So I searched the Web and found some contradictory information. I will explain what I think is the situation, to give you an answer, but also so that other people can tell me whether I understood correctly.
    1) Unless you sign it, an applet cannot write files directly, either client-side or server-side. All what it can do to access a file server-side (except .jar files ?) is opening a http connection, which allows only to retrieve data. When I try to run code such as yours, I get this exception :
    java.net.UnknownServiceException: protocol doesn't support output
         at java.net.URLConnection.getOutputStream(URLConnection.java:679)
    2) As Ares_Man points out, what it can do is opening a http connection not directly with the file you want, but with a server-side script (JSP, PHP, CGI,...) which will be allowed to write files on the server. You can use POST or GET parameters to pass to the script what you are going to write.
    This simple code worked for me (it executed the script toto.php):
              try{
                   URL toto=new URL(getCodeBase(),"toto.php");
                   InputStream f=toto.openStream();
                   f.close();
              catch(Exception e){
                   e.printStackTrace();
    Probably it's a good idea to do a URLConnection.setCache(false) though, to be sure that the script toto.php will be executed.
    3) I don't know how you can pass serialized objects as parameters. So if more than text informations are to be written, I would tend to make the script store them into a database instead of files. That way, you could pass any SQL query as parameter, maybe along with a password parameter for security. I don't know whether this is secure enough.

  • Error while accessing a file located in the server from JSP

              Hi
              I am having problem while accessing the file located in the server from a JSP
              page. I am not getting the RealPath from a JSP page using getRealPath(request.getServletpath()).
              The same code is working if the jsp placd under defaultwebApp directory and not
              working if i create a war and deploy the same.
              I am using weblogic server 7.0 trail version.I am setting the context path also.
              Can any help me in this regard.
              Thank And Regards
              Anand Mohan
              

              Hi
              Thank you.Is there a way to read a file which is existing in the war file.
              Regards
              Anand Mohan
              "Wenjin Zhang" <[email protected]> wrote:
              >
              >In Weblogic, if your files are archived in a WAR, you cannot get an entry
              >as individual
              >file since it is only bytes in a large archive file. So getRealPath will
              >give
              >you null result. If you only want the path, try to use other getXXXPath,
              >getURL,
              >or getURI method. If you want to read the content, use getResource.
              >
              >
              >"Anand" <[email protected]> wrote:
              >>
              >>Hi
              >>I am having problem while accessing the file located in the server from
              >>a JSP
              >>page. I am not getting the RealPath from a JSP page using getRealPath(request.getServletpath()).
              >>
              >>The same code is working if the jsp placd under defaultwebApp directory
              >>and not
              >>working if i create a war and deploy the same.
              >>
              >>I am using weblogic server 7.0 trail version.I am setting the context
              >>path also.
              >>
              >>Can any help me in this regard.
              >>
              >>Thank And Regards
              >>
              >>Anand Mohan
              >
              

  • Mac mini Server 10.6  unable to search for files on the server from desktop.

    I'm running Mac mini Server 10.6 with 15 various Apple Mac desktops 10.4 / 10.6. The problem i'm having is that i'm unable to search for files on the server from any of the desktops. I have fixed permissions and rebooted. I can perfomr a search though command - F and spotlight from the server.
    Anyone have any ideas?

    I have a Mac mini server with Mac osx 10.6.8 installed --- I have a website {UNDER CONSTRUCTION} installed on it with a REGISTERED DOMAIN NAME belizeansworldwide.com -->[DNS service w/GoDaddy]  & DSL INTERNET service  w/VERIZON --- {My server is the ONLY DEVICE CONNECTED to my VERIZON DSL router/modem}
    When I enter my DOMAIN NAME or WAN IP # in my browser(s)--> Chrome OR Safari -- i get my Verizon modem
    set-up page-->{this incl the WAN IP# as I expected}----{NORMALLY I WOULD ACCESS MY Actiontec
    modem/router via 192.168.1.1} --- While in that webpage there's an option "shared files/folders"   & clicking on that option DISPLAYS MY WEBSITE --->  {"PORT FORWARDING DID NOT RESOLVE THAT"}
    My next attempt @ a solution was through my Server's SystemPreference>Sharing>Internet Sharing
    & this the Original Object of my post ===>  "MY SHARING PANEL DOES NOT INCLUDE THE OPTION
    FOR   'Internet Sharing' among the others like CD DVD, Remote Login,Remote Management, Bluetooth Sharing, etc.etc ---- Hope this additional info will help to clarify  &/or explain my problem
    Thanks, & best regards to you & yours

  • I have a Mac on my home network and also a Systemline music server on same network. My PC was able to find the server but my MAC cannot. I can ping the server from the mac, but cannot actually connect . Also can't add the mac as a location from server

    I have a Mac on my home network and also a Systemline music server on same network. My PC was able to find the server but my MAC cannot. I can ping the server from the mac, but cannot actually connect . Also can't add the mac as a location from server, despite following the Systemline instructions that impy this can be done.
    Can anyone please advise what I am doing wrong?

    Hi LowLuster
    Thanks for reply. I am not an expert on these sharing protocols but I think I have turned on SMB sharing but still wont connect. I tried adding netwrik drive by using cntrl K in finder and using smb\\network address but nothing. It is driving me mad!!

  • How do I gracefully shutdown the server from a script?

    I have a shutdown class that stop the server.
    When I'm using 'stop the server' from the console (after configure a
    new shutdown class to config.xml) it work good.
    How do I do the same from a script (cmd, bat or sh - doesn't metter).

    http://edocs.bea.com/wls/docs81/ConsoleHelp/startstop.html#1212202
    "avishosh" <[email protected]> wrote in message
    news:[email protected]..
    I have a shutdown class that stop the server.
    When I'm using 'stop the server' from the console (after configure a
    new shutdown class to config.xml) it work good.
    How do I do the same from a script (cmd, bat or sh - doesn't metter).

  • Data types, msg types, where these data saved in the server?

    In XI we are creating the data types, msg types, ...... where these data saved in the server ?

    Enter CL_SRAPI* in the SE24 transactions and make your search as shown below.
    CL_SRAPI_DATA_TYPE----
    data type
    CL_SRAPI_DATA_TYPE_ENH----
    data type  enhancement
    CL_SRAPI_FAULT_MESSAEG_TYPE-----fault message type
    CL_SRAPI_MESSAGE_TYPE----
    message type
    CL_SRAPI_INTEGRATION_SCENARIO----integration scenario
    Communication channels are saved in the SMPREL3 database table.

  • The data could not be saved because the server could not be contacted - Error

    Hello, I'm a beginner in ligthswitch, so, I made a couple of screens and I made the database and attach to the application but when i want to save the new records shows me this error:
    The data could not be saved because the server could not be contacted. Please check your network connection and try saving again.
    The operation has timed out.
    I verify the database, the record is saved but the application show me the error.
    Please help me I have to deliver this screens today.
    Thanks!
    Boanerges. Mr 3: 17

    Hi Elmer,
    I researched this error message, I think you can try the methods below:
    Increase the timeout of the connection between the client and the server
    Increase  Client timeout, and it is set in the Application class in the Client Project
    For further information: Error message: Unable to save data

  • LS Getting the error "The data could not be saved because the server could not be contacted" when deploying on my local desktop

    Hi:
    I have a very simple test LS App:
    1 Table "Person" with 1 property "Name"
    One totally standard Editable Grid
    So no complicated calculations that could timed out...
    When I hit F5 the screen launches and shows the data, but when I try to create a new Person it waits for about 2 minutes and then the following error appears:
    The data could not be saved because the server could not be contacted. Please check your network connection and try saving again. The Operation timed out.
    Despite the error the data gets persisted on the database.
    I am on VS 2013 Pro Update 4 and SQL Server LocalDB 2012 (v11.0).

    If you decide to try again I would:
    1) Uninstall Visual Studio
    2) Uninstall SQL Server (all versions)
    3) Re-install SQL Server
    4) Re-Install Visual Studio
    Unleash the Power - Get the LightSwitch 2013 HTML Client / SharePoint 2013 book
    http://LightSwitchHelpWebsite.com

  • Multiple users working using the server from laptops

    Hello everyone.
    We have a Mac Mini Server in the house, and a couple of Mac laptops.
    I know that using screen sharing I can control the server from a laptop. However, when doing this whoever is physically sitting at the server will see their mouse possessed and not be able to do their own thing on the server.
    Given the fact that we have multiple users, would it be possible to have multiple people use their laptops to view the desktop of the server as they work on it, while logged in to their own individual user accounts, and control the server independently through those accounts?
    Not sure if that description was clear or not, but I think you'll get my gist. Basically I want to use the laptops as thin clients to work using the server. Also key is that multiple people be able to do this at the same time.
    Thanks for any suggestions!

    The Mac OS X graphical interface is a single-seat design. One Mac, one seat.
    There is no analog to Microsoft Windows Terminal Services, nor to multiple sessions on Windows XP Pro or analogous, nor multi-seat X Windows, nor to Thin Clients, with Mac OS X nor Mac OS X Server, short of the add-on package Aqua Connect or analogous.
    One of the usual mechanisms for controlling a Mac OS X Server is via the Server Admin tools. These are independent.
    Command-level management operations are also available via ssh and analogous. You can ssh into the server and manage many of the aspects of Mac OS X client and Mac OS X Server from the command line. These are fully independent sessions.
    Typical Mac OS X Server doesn't require all that much management, and it's probably not the best to have an interactive user operating on a server box regardless. This because servers typically support multiple users, so outages and reboots and operational errors and crashes will effect more than just the user in the seat at the server.

Maybe you are looking for

  • How do I burn files into a CD other than by burning music through iTunes?

    How do I burn files into a CD other than by burning music through iTunes?

  • Apple Studio 17" Display colors not right after thunderstorm

    Noticed this afternoon, after a thunderstorm, that my 17" Apple Studio Display was not displaying colors correctly. All windows are reversed - white background is now black and text is white. Also photos look like 35mm negatives. My blue Apple standa

  • Help!!! Got 3G S - Lost of  paid applications plus freezing issue!

    Got my iPhone 3G S earlier today. Hooked it up to activated! So far all is good! The bad news is that applications that i paid for did not transfer over on my new iPhone3G S !!!! So was the case with applications the were free. The free ones are not

  • ProRes HVX backup solution.

    Just wondering from a P2 standpoint and workflow...... I as of now shoot interviews using P2 cards and a laptop or P2 store. Than i take the footge and put the media on two seperate external drives. So with ProRes just to be clear I can take current

  • Problems with IEM 7.1.1

    Hello, When trying to add a IPS(ASA-SSM-20) 7.0(2)E4 to IME I recieve the following message : Could not verify config username/password [IOEXception -Read timed out] This problem came when EMI sensor delete, add it back and walked out the message des