Using Jakarta HttpClient API for HTTPS file upload

Any code sample on how to upload a file via the Jakarta HttpClient API?
I tried the PostMethod, not sure I used it right, got response msg from the server response code 301, which indicated the file had been permanently moved. What did that mean? Besides, I didn't see PutMethod have a way to specify the target uploaded file filename, it only take a File object.
Tried the PutMethod as well, but the method I though I can use was "depreciated".
Any idea?
jml

I did. The sample code use the PutMethod and specify the file object. But when I use the similar code, I got 301, which means "File permanently moved". Not sure what that mean.
jml

Similar Messages

  • How to read .doc files using jakarta POI api......

    Hi all,
    I've googled a lot on reading the file contents of an MS word file. I couldn't get a solution yet. Can you please give some sample codes for using the POI api for extracting only the text contents from an MS word file.
    Thanks and Regards,

    whenever i click the folders, it's taking
    to the internal folders. but there's no
    option to download the whole package.Thats because you're looking at a tool which displays the contents of an svn repository through a web site.
    What you need is a subversion client (the repository is a subversion repository).
    There are several easy to use clients available:
    Here's two:
    1) subclipse: If you use eclipse. Dammed great tool IMHO. http://subclipse.tigris.org/
    2) tortoise svn http://tortoisesvn.tigris.org/
    When you've got a client, you'll need to give it a repository URL from which to check out.
    For the POI project, that URL is http://svn.apache.org/repos/asf/jakarta/poi/trunk/
    ~D

  • Importing Hotmail Address Book using Jakarta HttpClient

    Hi,
    I am using jakarta httpclient to import hotmail address book. For that i am loading the login form first and then retrieving dynamic parameters and then posting the form for authentication of user.
    I am unable to authenticate user after posting the form , it redirects me to the login page.
    Can somebody help me to figure out what i am missing in my code??
    Following is the code i have written so far:
    (To run java one will need to enter hotmail emailId and password in the loginData)
    package msn.contacts.fetcher;
    import java.io.InputStream;
    import org.apache.commons.httpclient.Header;
    import org.apache.commons.httpclient.HttpClient;
    import org.apache.commons.httpclient.HttpStatus;
    import org.apache.commons.httpclient.NameValuePair;
    import org.apache.commons.httpclient.cookie.CookiePolicy;
    import org.apache.commons.httpclient.methods.GetMethod;
    import org.apache.commons.httpclient.methods.PostMethod;
    import org.cyberneko.html.parsers.DOMParser;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.InputSource;
    public class MSNContactsFetcher {
         private String msnLoginUrl = "http://login.live.com/login.srf";
         public void login(){
              HttpClient httpClient = new HttpClient();
              httpClient.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
              int statusCode = -1;
              InputStream responseStream = null;
              DOMParser parser = null;
              InputSource source = null;
              try{
                   GetMethod loadForm = new GetMethod(msnLoginUrl);
                   loadForm.setFollowRedirects(true);
                   statusCode = httpClient.executeMethod(loadForm);
                   /*Header[] headers = loadForm.getResponseHeaders();
                   for(int i= 0;i<headers.length;i++){
                        System.out.println("Header name:: " + headers.getName() + " value::: " + headers[i].getValue());
                   System.out.println("Hotmail Status Code::: " + statusCode );          
                   if(statusCode == HttpStatus.SC_OK){
                        System.out.println("Hotmail Login Form Loaded Successfully");
                        System.out.println(loadForm.getResponseBodyAsString());
                        //System.exit(1);
                        String PPFT = null;
                        String PPSX = null;
                        String loginFormAction;
                        parser = new DOMParser();
                        responseStream = loadForm.getResponseBodyAsStream();
                        source = new InputSource(responseStream);
                        parser.parse(source);
                        Node form = parser.getDocument().getElementsByTagName("form").item(0);
                        NamedNodeMap attributes = form.getAttributes();
                        String formAction = attributes.getNamedItem("action").getNodeValue();
                        System.out.println("Form action ::: " + formAction);
                        NodeList inputElements = parser.getDocument().getElementsByTagName("input");
                        Node inputNode;
                        String name;
                        for(int i=0;i<inputElements.getLength();i++){
                             inputNode = inputElements.item(i);
                             name = inputNode.getAttributes().getNamedItem("name").getNodeValue();
                             //System.out.println(name + " " + inputNode.getAttributes().getNamedItem("value").getNodeValue() );
                             if(name.equals("PPFT")){
                                  PPFT = inputNode.getAttributes().getNamedItem("value").getNodeValue();
                             else if(name.equals("PPSX")){
                                  PPSX = inputNode.getAttributes().getNamedItem("value").getNodeValue();
                             else if(PPFT != null && PPSX!= null)
                                  break;
                             else
                                  continue;
                        System.out.println("PPFT::: " + PPFT + " PPSX::: " + PPSX );
                        NameValuePair[] loginData = {
                                  new NameValuePair("PPSX",PPSX),
                                  new NameValuePair("PwdPad","IfYouAreReadingThisYouHaveTooMuc"),
                                  new NameValuePair("login","<emailId>"),
                                  new NameValuePair("passwd","<password>"),
                                  new NameValuePair("LoginOptions","3"),                              
                                  new NameValuePair("PPFT",PPFT)                              
                        PostMethod postLoginForm = new PostMethod(formAction);                         
                        postLoginForm.setRequestBody(loginData);
                        httpClient.executeMethod(postLoginForm);
                        statusCode = postLoginForm.getStatusCode();
                        System.out.println("Status Code::: " + statusCode);
                        String responseString = postLoginForm.getResponseBodyAsString();
                        System.out.println("Response string:: " + responseString);
              }catch(Exception ex){
                   System.out.println("Exception Occurred -->> " + ex.getMessage());
                   ex.printStackTrace();
         public static void main(String[] args) {
              System.getProperties().setProperty("httpclient.useragent", " Mozilla/5.0 (Win98; I;Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4");
              System.setProperty("org.apache.commons.logging.Log","org.apache.commons.logging.impl.SimpleLog");
              System.setProperty("org.apache.commons.logging.simplelog.showdatetime","true");
              System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header","debug");
              MSNContactsFetcher msn = new MSNContactsFetcher();
              msn.login();

    are you having issues with the initial login, or is hotmail successfully taking your information, but failing to remember it when you access more of the site for address book information gathering?
    If the first part is happening, you're probably not setting up your connection within a SSL environment correctly (I'm only guessing that's what hotmail uses, as I'm not a hotmail user). There's plenty of documentation on apache's jakarta site on how to do this/troubleshoot it.
    If you're connecting, and it's not holding the information, then the cookie storing is not set up right. In that case, you may want to post a new topic more specifically relating to cookies (probably want to do it in the networking section of these forums, as it's far more pertinent there).
    I wish I could help you more, but I am far more familiar with instantiating web connections via the UrlConnection class, and not with the Jakarta Commons libraries. :(

  • Trouble for do file upload

    I use <hx:fileupload> tag to do file upload, but it doesn't work.
    I tye to find doc, but it doesn't talk more.
    my code:
    <h:form id="form1">
    <hx:fileupload styleClass="fileupload" id="fileupload1" value="#{pc_Upload.uploadfile}" required="true">
    <hx:fileProp name="fileName" value="#{pc_Upload.fileName}"/>
    <hx:fileProp name="contentType" value="#{pc_Upload.mimeType}"/>
    </hx:fileupload>
    <h:message for="fileupload1"></h:message>
    <h:commandButton value="upload" action="#{pc_Upload.doCommandButtonAction}"></h:commandButton>
    </h:form>uploadfile is boolean , fileName and mimeType are String
    I can't get fileName and mimeType in my backing bean and this give me a message for validator fails need value!, why?
    where can I do something to let it work?
    please tell me , thanks

    it's still NullPointException
    upload.jsp
    <f:view>
         <BODY><hx:scriptCollector id="scriptCollector1">
         <P>Place content here.</P>
              <h:form styleClass="form" id="form1">
                   <hx:fileupload styleClass="fileupload" id="fileupload1" binding="#{backingUpload.file}">
                        <hx:fileProp name="fileName" />
                        <hx:fileProp name="contentType" />
                   </hx:fileupload>
                   <hx:commandExButton type="submit" value="Submit"
                        styleClass="commandExButton" id="button1" action="#{backingUpload.update}"></hx:commandExButton>
              </h:form>
         </hx:scriptCollector></BODY>
    </f:view>BackingUpload.java
    import com.ibm.faces.component.html.HtmlFileupload;
    import com.ibm.faces.fileupload.util.ContentElement;
    public class BackingUpload {
         private HtmlFileupload file;
          * @return Returns the file.
         public HtmlFileupload getFile() {
              return file;
          * @param file The file to set.
         public void setFile(HtmlFileupload file) {
              this.file = file;
         public String update() {
              HtmlFileupload tmpFile = this.getFile();
              ContentElement content = (ContentElement)tmpFile.getValue();
              if (content == null) {
                   System.out.println("is null!");
              return "update";
    }now when I enter upload.jsp
    console thows message to me, like this
    [2006/6/20   21:28:34:370 CST] 0000002a ServletWrappe A   SRVE0242I: [JS Resource Servlet]: �����������O����
    [2006/6/20   21:28:34:542 CST] 0000002b WebContainer  E   SRVE0232E: �����������e�`��<br> �������r������[java.lang.NullPointerException
         at com.ibm.ws.webcontainer.srt.SRTServletResponse.setDefaultResponseEncoding(SRTServletResponse.java:610)
         at com.ibm.ws.webcontainer.srt.SRTServletResponse.start(SRTServletResponse.java:494)
         at com.ibm.ws.webcontainer.srt.SRTConnectionContext.start(SRTConnectionContext.java:48)
         at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1654)
         at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367)
         at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:94)
         at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548)
         at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
         at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934)
         at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021)
         at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1332)
    ]What do I set in web.xml and faces-config.xml, if I want to user fileupload?
    or What can I do to it
    please help me, thanks

  • Is Using the COM API for Integration still valid for UCM 11g?

    Dear All,
    One of our partners is trying to implement integration to UCM by using the COM API (described http://download.oracle.com/docs/cd/E17904_01/doc.1111/e10807/c08_com.htm#i1084682).
    However, they cannot follow the manual, because the environment does not correspond to the written text:
    -     8.2.1 To set up IdcCommandUX, run the IdcCommandUX setup file, which is stored in extras/IdcCommandUX/setup.exe in the media. – no such directory exists (neither extras, nor IdcCommandUX); ‘extras’ used to be in 10g, though
    -     8.2.3 1. Add the IdcCommandUX control to the project . – according to the partner, this is supposed to mean that IdcCommandUX.ocx must exists somewhere – there is no such file to be found
    -     8.4 speaks about “IntradocClient OCX component”, 8.5 speaks about “IdcClientOCX Component” – the system has only IdcClient component, which contains only idcclient.jar
    Could anyone confirm that COM API is still available in 11g? If so, what steps need to be followed to make it running?
    Thanks in advance, Jiri

    For what it's worth, I had no problems migrating an authentication plugin from 4 to 5. This is really good, because otherwise I wouldn't be able to use 5.1.

  • Project Oxford. Can I use the Face API for law enforcement app

    Hello,
    I am a .Net developer and have recently learned of Microsoft's Project Oxford.
    I am very much interested in developing an app using the Face API but, had a question regarding the code of conduct.
    Specifically it states:
    People who use your app must have the consent of the people whose images are being processed by your app. We ask that you include a prominent notice in your app UI so your end users know that consent
    is required.
    The  application I am attempting to develop is for law enforcement to detect wanted persons while out on patrol.
    My questions are: 
    1. Is there an exception to the rule above for law enforcement?
    2. Can I use the Face api for my application knowing that
    in most cases law enforcement will not specifically ask for consent while scanning people?
    As always thank you for your assistance.

    https://www.apple.com/legal/intellectual-property/guidelinesfor3rdparties.html

  • How to increase page size for balance file upload in Workspace.

    Hi All,
    Please suggest how to increase page size for balance file upload in shared Workspace pages.
    Thanks,

    A word of caution is in order regarding changing from facing to non-facing and back again. If you have overridden master page items, you'll get a second, non-overridden copy on all the even-number pages when that half of the master page is re-applied. This applies to master text frames which override automatically when text flows into them as well as to objects you manually override. I think you'll find this particular technique also only works for master text frames, whereas the Layout Adjustment should work in all situations where frames snap to guides.

  • Can I use Photoshop Elements 10 for RW2 files used by Panasonic?

    Can I use Photoshop Elements 10 for RW2 files used by Panasonic?
    Message title was edited by: Brett N

    PSE supports RW2 from the Lumix DMC-GH1

  • Applet for multiple file upload

    Hi All
    I have a requirement for multiple file upload where user can select multiple files as well as folders.
    Would appreciate any pointers.
    Thanks.

    Google "java file upload"

  • Any socket programming sample program or API for transfer file?

    Do there any java socket programming sample program or API for transfer file ,list file and make directory from client side?
    Thank you

    http://forum.java.sun.com/thread.jspa?threadID=603685&tstart=0

  • Error while using LiveCycle java APIs with Http servlets:"Remote EJBObject lookup failed for ejb/Inv

    Hi all,
    When i try to run more than one servelt of the Quick Start samples that using Livecycle Java APIs and i get an error of "Remote EJBObject lookup failed for ejb/Invocation provider" from any servelt i run.
    I try some Quick samples which is not servelts (java class) and it works fine, which makes me sure that my connection properties is true.
    Environment:
    The LiveCycle is based on "Websphere v6.1", and i use "Eclipse Platform
    Version: 3.4.1".
    i install "tomcat 5.5.17" to test the servelts in developing time through Eclipse.(only for test in developing time not for deploy on )
    The Jars i added in the classpath:
    adobe-forms-client.jar
    adobe-livecycle-client.jar
    adobe-usermanager-client.jar
    adobe-utilities.jar
    ejb.jar
    j2ee.jar
    ecutlis.jar
    com.ibm.ws.admin.client_6.1.0.jar
    com.ibm.ws.webservices.thinclient_6.1.0.jar
    server.jar
    utlis.jar
    wsexception.jar
    My code is :
    Properties ConnectionProps = new Properties();
    ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "iiop://localhost:2809");
    ConnectionProps.setProperty ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_ EJB_PROTOCOL);
    ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE,ServiceClientFa ctoryProperties.DSC_WEBSPHERE_SERVER_TYPE);
    ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "Administrator");
    ConnectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
    ConnectionProps.setProperty("java.naming.factory.initial", "com.ibm.ws.naming.util.WsnInitCtxFactory");
    //Create a ServiceClientFactory object
    ServiceClientFactory myFactory = ServiceClientFactory.createInstance(ConnectionProps);
    //Create a FormsServiceClient object
    FormsServiceClient formsClient = new FormsServiceClient(myFactory);
    //Get Form data to pass to the processFormSubmission method
    Document formData = new Document(req.getInputStream());
    //Set run-time options
    RenderOptionsSpec processSpec = new RenderOptionsSpec();
    processSpec.setLocale("en_US");
    //Invoke the processFormSubmission method
    FormsResult formOut = formsClient.processFormSubmission(formData,"CONTENT_TYPE=application/pdf&CONTENT_TYPE=app lication/vnd.adobe.xdp+xml&CONTENT_TYPE=text/xml", "",processSpec);
    List fileAttachments = formOut.getAttachments();
    Iterator iter = fileAttachments.iterator();
    int i = 0 ;
    while (iter.hasNext()) {
    Document file = (Document)iter.next();
    file.copyToFile(new File("C:\\Adobe\\tempFile"+i+".jp i++;
    short processState = formOut.getAction();
    ...... (To the end of the sample)
    My Error was:
    com.adobe.livecycle.formsservice.exception.ProcessFormSubmissionException: ALC-DSC-031-000: com.adobe.idp.dsc.net.DSCNamingException: Remote EJBObject lookup failed for ejb/Invocation provider
    at com.adobe.livecycle.formsservice.client.FormsServiceClient.processFormSubmission(FormsSer viceClient.java:416)
    at HandleData.doPost(HandleData.java:62)
    at HandleData.doGet(HandleData.java:31)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j ava:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    a

    I assume here that your application is deployed on a different physical machine of where LCES is deployed and running.
    Do the following test:
    - Say that LCES is deployed on machine1 and your application is deployed on machine2. Ping machine1 from machine2 and note the ip address.
    - Ping machine1 from machine1 and note the ip address.
    The two pings should match.
    - Ping machine2 from machine1 and note the ip address.
    - Ping machine2 from machine2 and note the ip address.
    The two pings should match.
    Usually this kind of error would happen if your servers have internal and external ip addresses.

  • RE: HTTP File upload using WebEnterprise

    AFAIK, WebEnterprise does not support the multipart-mime file upload
    feature. I think this is something that is targeted for the next
    release.
    On a project here we wrote our own cgi program to handle file uploads,
    but unfortunately this was not integrated with the rest of the Forte
    backend. The suggestion from Forte was to make C++ calls into our Forte
    service objects from our CGI. We haven't yet implemented this, but it
    certainly seems like it will be possible.
    By all means, let us know if you find a better mechanism than this.
    It's certainly not the cleanest in the world.
    Sam Yates
    Systems Analyst
    Amgen, Inc
    [email protected]
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Hi,
    You should have a parameter called ServiceName in your request
    (either in the URL or as a hidden parameter in the form) for any request
    you send to fortecgi. The cgi uses this information to send your request
    to the proper forte application.
    In your example you would need something like this
    <FORM ENCTYPE=3D"multipart/form-data" ACTION=3D"...." METHOD=3DPOST>
    Send this file: <INPUT NAME=3D"userfile" TYPE=3D"file">
    <INPUT TYPE=3D"submit" VALUE=3D"Send File">
    <INPUT TYPE="Hidden",Name="ServiceName",Value="MyService">
    </FORM>
    MyService is the name is the name you have given for the service when
    you call EnableAccess in your subclass of HTTPAccess.
    This is all explained in the Web Enterprise /SDK manual.
    Note : You would also need a parameter PageName when using Web SDK. I
    have not used Web Enterprise yet but I presume it is the same there too.
    Hope this helps
    Santha Athiappan
    Get Your Private, Free Email at http://www.hotmail.com
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • APIs for XML file creation

    hi,
    can anyone tell me whether there is any Java APIs for creating XML file( similar to the one used for parsing).
    thx in advance,
    -Soni.

    Hi,
    you can try the org.apache.xml.serialize.XMLSerializer which is included in the Apache Xerces Package (http://xml.apache.org/xerces). This Class allows you to serialize a org.w3c.dom.Document to a OutputStream which can be a FileOutputStream.
    Check out this code:
    OutputFormat format = new OutputFormat();
    format.setDoctype("mapping","mapping.dtd");
    format.setEncoding("ISO-8859-1");
    format.setLineWidth(100);
    XMLSerializer ser = new XMLSerializer(new FileOutputStream(f),format);
    ser.serialize(doc);
    Rgds,
    Sebastian

  • How to add a field for multiple file upload in WebApps ?

    I am creating a WebApp for user to save some information with multiple pitcures. I can only see a single uploader.
    How can I add multiple image uploader and How can I create a custom file upload field rather than image upload ?

    Hi,
    There's no other upload field type for web apps.  You'll need to use the "image file type" to apply multiple file upload fields within the web app form in this case.
    Kind regards,
    -Sidney

  • How To guide...for Flat File upload for User-Defined variables

    Has anyone got link to the guide that describes how to do a flat file upload for populating User-Defined Variables ?
    Any assistance will be appreciated.
    Uche

    SAP BW Business Planning and Simulation "How To" Guides
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ab9fd590-0201-0010-2590-be78eb70015c
    How to Upload User-Specific Variable Selections in BW-BPS
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/how to upload user-specific variable selections in bw-bps.pdf
    this is what you are looking for ?
    Message was edited by: Murali

Maybe you are looking for

  • 10.2.0.3 Patch

    Tried to apply the 10.2.0.3 RDBMS patch to 10.2.0.1 Client. Installer stated there is nothing to patch. Is there a separate 10.2.0.3 patch for the 10.2.0.1 Client?

  • HT1409 Problems adding artwork in iTunes on my mac

    In iTunes I can open the Get Info file tabs for any of my new files and I can add information ok, but I cannot seem to add artwork which used to be the simplest of tasks on my old PC. I can get to the artwork tab and add artwork for a file and althou

  • Batch file to archive the logs

    I have log file under below directory (actually multiple directories with different names under E:\TIBCO\) E:\TIBCO\*\6.0.0\LogFiles with Spotfire.Dxp.Automation.*.* I need to get perform below steps with the batch script 1. move (copy & delete) all

  • "Poodlefaking" VISTA so  Abap trial SP12 can work

    Any Windows Gurus out there who know how to "fool" the abap tral netweaver that it's going to be installed on XP when it's actually being installed on Vista. These days it's almost impossible to get a new computer (individual retail level - not corpo

  • No Music when Airplaying a Slideshow from iOS Photos

    The Photos App in iOS 8 has a slideshow feature which (in theory) allows you to play a slideshow of all photos in an album with a variety of transitions and with music selected from your iTunes library. The slideshow is initiated from a slideshow but