Opening Output Stream to a file on the server from Applet

Hi,
I am trying to write a little applet which parses a file found on the server , lets the user select some Strings then write the selected Strings to a different file on the server. I use the following code:
String fileName = new String("LineUp");
URL docBase = null;
URLConnection conn = null;
try {
docBase = new URL(ApppletName.codeBase, fileName);
} catch (java.net.MalformedURLException e) {
System.out.println("Couldn't create image: "
+ "badly specified URL");
try {
conn = docBase.openConnection();
} catch(IOException e) {System.out.println(e);}
String playerString;
try {
conn.setAllowUserInteraction(true);
conn.setDoOutput(true);
conn.connect();
PrintWriter out = new PrintWriter(
conn.getOutputStream());
etc..
The problem I am having is that the getOutputStream routine for the connection object does nothing other than throw an exception (I've stepped through the code and that is all the routine actually does). The connection is actually made but no output stream can be created. I have looked at the Java Tutorial (as I am fairly new to Java) and found a spot where they tell you how to write to a file on the server, which is the example I have followed. Any suggestions? What am I missing?

Yes, that's what I thought. It talks about writing to a URL, and you have interpreted "URL" as if it meant "file". A URL is a "Uniform Resource Locator", which is a string that identifies a "resource" on the server. Often that corresponds to a file on the server, but not always. It could be a page that is dynamically generated by a script on the server.
Look again at that page and you will see these words: "At the other end, a cgi-bin script (usually) on the server receives the data, processes it, and then sends you a response, usually in the form of a new HTML page." What that means is, you can't just upload a file to a URL unless you have programmed the server to deal with that upload. That's part of the basic design of the HTTP protocol.
So, unfortunately, you can't do what you want all that easily. You would have to provide some programming at the server to handle the file upload for you. In Java that means writing a servlet and getting the web server to have that servlet handle all requests to a particular URL. I suspect you don't want to get into that just yet. But if you do, any decent book on Java servlets should have an example of how to upload files like this.

Similar Messages

  • 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

  • How to Upload a File on the Server

    Hi,
    I want to upload a file on the server from Windows Mobile Application. Can anyone please suggest me a way to do so?
    Thanks in advance, 
    Saheli Sur

    Following links should also help
    http://blog.anthonybaker.me/2013/06/how-to-upload-file-from-windows-phone.html
    http://stackoverflow.com/questions/19954287/how-to-upload-file-to-server-with-http-post-multipart-form-data/20000831#20000831
    Gaurav Khanna | Microsoft .NET MVP | Microsoft Community Contributor

  • TS3989 Mssage when opening Photo Stream on-"This file does not have a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the Default Programs control panel" Help!!!

    Mssage when opening Photo Stream on-"This file does not have a program associated with it for performing this action. Please install a program or, if one is already installed, create an association in the Default Programs control panel" Help!!!

    You are posting in the "icloud on my mac" forum, but your profile mentions Windows.  If using a mac, you need to have iphoto or aperture installed in order to receive new photos via photo stream.  If using windows, try posting in the iCloud on a PC forum.  You'll get better help there.
    https://discussions.apple.com/community/icloud/icloud_on_my_pc

  • How do I change the default folder that opens when uploading a file to the internet from my mac? (at the moment it automatically defaults to 'Downloads' folder)

    How do I change the default folder that opens when uploading a file to the internet from my mac? (at the moment it automatically defaults to 'Downloads' folder)
    For example...
    I am on a webiste and wish to upload a photo.
    I click on select file on the website
    Finder opens and defaults to 'Downloads' folder (it happens with all wesbites)
    How do I change this?

    I am on a webiste and wish to upload a photo.
    I click on select file on the website
    You are attempting to download the picture to your computer not uploading photo to the website if I am understanding you correctly.
    To change the download direction, you must do so through your browser's Preferences.  If you are using Safari, hopefully, someone who uses Safari will help you and/or post over in their forums.  I do not use Safari.
    If using Firefox>Preferences>General>Save Files to:

  • To open a Excel and Doc file inside the AIR application

    How to open a Excel and Doc file inside the AIR application.  I have opened the PDF file inside the AIR application.  But i got stuck in opening the Exce and Doc file.  Please help me in this issue.

    AIR does not support this inherently. However, you could write code to parse these file formats. For example, the following is an ActionScript 3.0 library for reading and writing Excel files:
    http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1375018

  • Hello, I can see the Icon of my external hard on the mac os x 10.6.8 but I can not open it or view any file in the external hard

    hello, I can see the Icon of my external hard on the mac os x 10.6.8 but I can not open it or view any file in the external hard
    your prompt reply will be appreciated
    thanks

    Reinstall 10.6 again, but this time hold c boot off the 10.6 and erase the ENTIRE internal drive.
    You do this by selecting the drive makers name and size on the left hand side, not the slightly indented partition underneath it.
    If you erase and install 10.6 only into a parittion, say Macintosh HD, the you still have the hidden Lion Recovery Partition on the drive and it appears you already have 10.7
    In the MAS, hold option and click Purchases to redownload Lion
    FYI, you don't need to install 10.6 to reinstall 10.7, 10.7 can be reinstalled via the Lion Recovery, Command r boot.
    See this for more info
    https://discussions.apple.com/docs/DOC-3046

  • Saving report output to a file on the server.

    Hi,
    We are using BI Publisher Standalone version 10.1.3.3.1.
    Is it possible to schedule a report to output to a file on the server?
    I want the whole report to be saved as a file on the server.
    This is somewhat similar to bursting to a file system, but, I don't want to split the output.
    Any help is appreciated.
    Thanks,
    Nanda

    Yes, use the scheduler and schedule the report,
    do the bursting into FTP or
    schedule the report to run and run it into FTP as a single FILE.
    First option, you need to provide the query , with FTP server name, username, password etcccc.

  • When attempting to open a hyperlink to a PDF file on the web from a Microsoft WORD for Mac 2011 (14.3.9) document, Safari 7.0 instead displays the file as text?

    When attempting to open a hyperlink to a PDF file on the web from a Microsoft WORD for Mac 2011 (14.3.9) document, Safari 7.0 instead displays the file as text?

    As seen in http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macword/has-the-word- 2011-for-mac-invisible-toolbars/018a3ab6-0570-4ad5-abf8-5b6427fdde3e?msgId=e111b f0a-0e32-4fa3-9536-f349dad8439d
    and it worked for me:
    1. Quit Word
    2. In the Finder's menu bar, select Go > Go to folder and type or paste: ~/Library/Preferences/
    3. Click on Go
    4. Locate the preference file com.microsoft.Word.plist, then Option-drag it to the desktop to create a backup copy
    5. Go to Applications/Utilities and open Terminal
    6. Paste the following bold command at the $ prompt (it's a single line):
         defaults write com.microsoft.Word 14\\Toolbars\\Show_HIToolbar -boolean TRUE
    7. Press Return and then quit with Command Q
    8. Start Word and test. If the fix works, trash the backup file in the Desktop file. Otherwise, restore it.
    In the original source the author also mentions the change in Word 2008

  • Why does a gray screen display whenever I try to open a pdf (or any file) using the updated version of adobe

    Why does a gray screen display whenever I try to open a pdf (or any file) using the updated version of adobe

    Chances are you are looking at the place holder of a large image. Go to the preferences and check that View Large Images is checked.

  • Can you please make an update to open  and show itunes photo files on the computer as well as devices ????????? PLEASE?????????

    Can you please make an update to open and show itunes photo files on the computer as well as the devices ??????? PLEASE????????????? It's a real pain to view old photos for time and capacity reasons!!!!

    You seem to think you are talking to Omnifocus here.  The odds of actually reaching them here are practically 0%, I would guess.
    I suggest you go to the omnigroup forums and present your suggestions in the omnifocus forum.
    http://forums.omnigroup.com

  • Open The File in the Server

    Hi All,
    The macro OPENFILE is working fine for opening the files in the local.
    The same macro if used to open the file in the server its not working fine.
    I tried both in the following,
    evmnu("OPENFILE","link name","HTTP://server name/appsetname/application name/eEXCEL/REPORTS/Report1.xlt")
    evmnu("OPENFILE","link name","//server name/appsetname/application name/eEXCEL/REPORTS/Report1.xlt")
    both they are not working,
    Please let me know, if there is any problem in this or the procedure for accessing the files from the server.
    Thanks in Advance..
    Regards,
    G.Vijaya Kumar.

    Here is a working example if u want to open a report that is located in your local folder:
    =EVMNU("OPENFILE";"Description";"/REPORTS/WIZARD/template1.xlt")
    To open file that is located in a company folder on the root lvl u can use next formula:
    =EVMNU("OPENFILE";"Description";"CompanyLVLFile.xlt")
    Hope that was helpful,
    Dzmitry

  • How can I display the front panel of the dinamically loaded VI on the cliente computer, the VI dinamically loaded contains files, I want to see the files that the server machine has, in the client machine

    I can successfully view and control a VI remotly. However, the remote VI dinamically loads another VI, this VI loaded dinamically is a VI that allows open others VIs, I want to see the files that contains the server machine, in the client machine, but the front panel of the dinamic VI appears only on the server and not on the client, How can I display the fron panel with the files of the server machine of the dinamically loaded VI on the client computer?
    Attachments:
    micliente.llb ‏183 KB
    miservidor.llb ‏186 KB
    rdsubvis.llb ‏214 KB

    I down loaded your files but could use some instructions on what needs run.
    It seems that you are so close yet so far. You need to get the data on the server machine over to the client. I generally do this by doing a call by reference (on the client machine) of a VI that is served by the server. THe VI that executes on the server should pass the data you want to diplay via one of its output terminals. You can simply wire from this terminal (back on the client again) to an indicator of your choosing.
    Now theorectically, I do not think that there is anything that prevents use from getting the control refnum of the actual indicator (on the server) of the indicator that has the data, and read its "Value" using a property node. I have never tried this idea but it seems t
    hat all of the parts are there. You will need to know the name of the VI that holds the data as well as the indicator's name. You will also have to serve all VI's. This is not a good idea.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to Generate PDF file on the server

    Hello Everybody !
    I Need to generate a PDF File on the server, and I'm usin the command :
    "OPEN DATASET p_path FOR OUTPUT IN BINARY MODE message l_verro .
           LOOP AT t_lines.
             TRANSFER t_lines-tdline TO p_path.
           ENDLOOP.
           CLOSE DATASET p_path.  "
    The File was generated, but is corrupt . Don't Open the file, It's wrong.
    When I use the function GUI_DOWNLOAD the file is generated  right. But in the server not.
    Can someone help me please ??
    Best Regards,
    Wagner Duarte

    Hi.
    did you check this post?
    Download PDF File to SAP Application Server
    It doest the same as you are asking.
          " Write PDF Binary Data to App Server
        OPEN DATASET lv_filename FOR OUTPUT IN BINARY MODE.
        IF sy-subrc = 0.
          LOOP AT lines INTO ls_data.
            TRANSFER ls_data TO lv_filename.
          ENDLOOP.
        ENDIF.
        CLOSE DATASET lv_filename.
    Regards
    Miguel

  • How to upload a file to the server using ajax and struts

    With the following code iam able to upload a file ato the server.
    But my problem is It is working fine if iam doing in my system nd when iam trying to
    access theis application from someother system in our office which are connected through lan
    iam getting an error called 500 i,e internal server error.
    Why it is so???????
    Plz help me????????
    It is required in my project.
    I want the code to access from every system.
    My exact requirement is i have to upload a file to the server and retrive its path and show it in the same page from which we
    have uploaded a file.
    Here the file has to be uploaded to the upload folder which is present in the server.Iam using Tomcat server.
    Any help highly appreciated.
    Thanks in Advance
    This is my input jsp
    filename.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    <script type="text/javascript">
    alertflag = true;
    var xmlHttp;
    function startRequest(file1)
         if(alertflag)
         alert("file1");
         alert(file1);
    xmlHttp=createXmlHttpRequest();
    var video=document.getElementById("filepath").value;
    xmlHttp.open("POST","FilePathAction.do",true);
    xmlHttp.onreadystatechange=handleStateChange;
    xmlHttp.setRequestHeader('Content-Type', application/x-www-form-urlencoded');
    xmlHttp.send("filepath="+file1);
    function createXmlHttpRequest()
         //For IE
    if(window.ActiveXObject)
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
         //otherthan IE
    else if(window.XMLHttpRequest)
    xmlHttp=new XMLHttpRequest();
    return xmlHttp;
    //Next is the function that sets up the communication with the server.
    //This function also registers the callback handler, which is handleStateChange. Next is the code for the handler.
    function handleStateChange()
    var message=" ";
    if(xmlHttp.readyState==4)
         if(alertflag)
              alert(xmlHttp.status);
    if(xmlHttp.status==200)
    if(alertflag)
                                       alert("here");
                                       document.getElementById("div1").style.visibility = "visible";     
    var results=xmlHttp.responseText;
              document.getElementById('div1').innerHTML = results;
    else
    alert("Error loading page"+xmlHttp.status+":"+xmlHttp.statusText);
    </script></head><body><form >
    <input type="file" name="filepath" id="filepath" onchange="startRequest(this.value);"/>
    </form>
    <div id="div1" style="visibility:hidden;">
    </div></body></html>
    The corresponding action class is FIlePathAction
    package actions;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.*;
    public class FilePathAction extends Action{
         public ActionForward execute(ActionMapping mapping, ActionForm form,
                   HttpServletRequest request, HttpServletResponse response)
                   throws IOException, ServletException
              String contextPath1 = "";
              String uploadDirName="";
              String filepath="";
                        System.out.println(contextPath1 );
                        String inputfile = request.getParameter("filepath");
                        uploadDirName = getServlet().getServletContext().getRealPath("/upload");
                        File f=new File(inputfile);
    FileInputStream fis=null;
    FileOutputStream fo=null;
    File f1=new File(uploadDirName+"/"+f.getName());
    fis=new FileInputStream(f);
         fo=new FileOutputStream(f1);
                        try
         byte buf[] = new byte[1024*8]; /* declare a 8kB buffer */
         int len = -1;
         while((len = fis.read(buf)) != -1)
         fo.write(buf, 0, len);
                        catch(Exception e)
                                  e.printStackTrace();
                        filepath=f1.getAbsolutePath();
                        request.setAttribute("filepath", filepath);
                        return mapping.findForward("filepath");
    Action-mappings in struts-config.xml
    <action path="/FilePathAction"
                   type="actions.FilePathAction">
                   <forward name="filepath" path="/dummy.jsp"></forward>
              </action>
    and the dummy.jsp code is
    <%=request.getAttribute("filepath")%>

    MESSAGE FROM THE FORUMS ADMINISTRATORS and COMMUNITY
    This thread will be deleted within 24 business hours. You have posted an off-topic question in an area clearly designated for discussions
    about Distributed Real-time Java. Community members looking to help you with your question won't be able to find it in this category.
    Please use the "Search Forums" element on the left panel to locate a forum based on your topic. A more appropriate forum for this post
    could be one of:
    Enterprise Technologies http://forums.sun.com/category.jspa?categoryID=19
    David Holmes

Maybe you are looking for

  • How to properly embed album art work into TV/Films itunes: home sharing lag

    My setup is a simple apple home sharing network. I have a mac mini running OS X 10.6.8 and itunes 11.0.4(4) it hosts a lot of music, DVD's that have been re-encoded and paid for content from itunes. The mac mini is conntected to the network over a ve

  • Error in receiver IDOC_AAE

    Hi Exparts, I am using PI 7.3. I have configured receiver IDOC_AAE as per the thread  http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/21717. [original link is broken] [original link is broken] [original link is broken] But if I check controll re

  • Macbook w/Apple Display Questions

    Hi, Two questions: 1. Would there be three connections between a Macbook and a Apple Display? a. DVI b. USB c. Firewire 2. How would the Macbook (1 FW 400 and 2 USB 2 ports) treat the 4 USB's and two FW 400 ports on the display? Thanks! Donny

  • New u201CData Connectivity u2013 Crystal Reportsu201D forum

    Dear Users, Current Crystal Reports Design forum reached almost 14 thousands threads and it became difficult to search, explore as well as to moderate. Some of you suggested branching out some subjects like Crystal Reports connectivity, Charts, Cross

  • InDesign crashing when running script on large files

    Hello, I have created a javascript that will: For each InDesign file inside of a specified directory { Open the file Find all textual elements with the specified character style Convert that textual element to a hyperlink Export the file to PDF (with