title: java.io.IOException: The filename, directory name, or volume label syntax is incorrect Error while writing to HTTP directory
body: <p>`<strong>I am writing a java code to upload files in HTTP server using JSF 2.0 wtih Servlet 3.0. When i am trying to uplaod the file to local system it works fine but if I specify the HTTP server url directory in http_path variable it gives "java.io.IOException: The filename, directory name, or volume label syntax is incorrect" error.</strong> </p>
  
  <ul>
  <li>Also there are no issue while accessing the HTTP location using Web browser and i was successfully able to download files via java code if i give the HTTP path given in http_path(used in Bean.java)  </li>
  <li><p>While debugging it fails at  file.createNewFile() line but if i specify local directory in http_path variable it doesnt give any problem;</p>
  
  <p>Can someone please let me know whether the HTTP url path given in http_path variable is correct or am i missing any important code?</p></li>
  </ul>
  
  <p>My Bean file:</p>
  
  <pre><code>@ManagedBean
  @RequestScoped
  public class Bean {
          private UploadedFile uploadedFile;
          public String submit() throws IOException {
          String fileName = FilenameUtils.getName(uploadedFile.getName());
          System.out.println("Uploaded File name is " + fileName);
  
          byte[] bytes = uploadedFile.getBytes();
          String http_path = "http://`172.21.11.108`/myhttp/";
          URLConnection http = new URL(http_path).openConnection();
          http.connect();
          System.out.println("permisssion" + http.getPermission());
          System.out.println("Url is " + http.getURL());
          System.out.println("String" + http.getConnectTimeout());
          FileOutputStream fop = null;
          System.out.println("File name " + http_path + fileName);
          File file = new File(http_path+fileName);
          System.out.println("File path" + file.getPath());
  
          if (!file.exists()) {
              file.createNewFile();
              System.out.println("entered file created");
          }
      fop = new FileOutputStream(file);
          System.out.println("File name " + http_path + fileName);
          fop.write(bytes);
          fop.flush();
          fop.close();
                                return "success";
  
      }
  </code></pre>
  
  <p>Error in Glassfish logs:</p>
  
  <blockquote>
    <p>INFO: File name is servlet_code_upload.txt INFO: File contentTypeis
    text/plain INFO: permisssion(java.net.SocketPermission
    <code>172.21.11.108</code>:80 connect,resolve) INFO: Url is http://<code>172.21.11.108</code>/myhttp/ INFO: String0 INFO: File name
    http://<code>172.21.11.108</code>/myhttp/servlet_code_upload.txt INFO: File
    pathhttp:`172.21.11.108`\myhttp\servlet_code_upload.txt 
    WARNING:</p>
    
    <h1>{bean.submit}: java.io.IOException: The filename, directory name, or volume label syntax is incorrect javax.faces.FacesException:</h1>
    
    <h1>{bean.submit}: java.io.IOException: The filename, directory name, or volume label syntax is incorrect    at</h1>
    
    <p>com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
      at javax.faces.component.UICommand.broadcast(UICommand.java:315)    at
    javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
      ... 36 more Caused by: java.io.IOException: The filename, directory
    name, or volume label syntax is incorrect     at
    java.io.WinNTFileSystem.createFileExclusively(Native Method)  at
    java.io.File.createNewFile(File.java:883)     at
    com.example.Bean.submit(Bean.java:59)     at
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)</p>
  </blockquote>