Results 1 to 2 of 2
  1. #1
    thenna is offline Member
    Join Date
    Aug 2013
    Location
    Bangalore
    Posts
    1
    Rep Power
    0

    Post Servlet request.getParameter() always return null value

    I'm working on simple client server communication using HttpPost. From the client side I'm setting a parameter(filename).

    At the server side when I try to get the parameter value it's always showing null. I tried using MultiPartEntity but even that is not working.

    Below is my client code:


    HttpPost httppost = new HttpPost("http://xxx.xxx.xxx.xxx:yyyy");
    InputStreamEntity reqEntity = new InputStreamEntity(
    new FileInputStream(dataFile), -1);
    reqEntity.setContentType("binary/octet-stream");

    // Send in multiple parts if needed
    reqEntity.setChunked(true);
    httppost.setEntity(reqEntity);

    //setting the parameter
    httppost.getParams().setParameter("filename", "xxxx.xml");
    HttpResponse response = httpclient.execute(httppost);
    int respcode = response.getStatusLine().getStatusCode();


    Below is my Servlet code:

    response.setContentType("binary/octet-stream");
    Scanner scanner = new Scanner(request.getInputStream());

    // reading the parameter
    String filename = request.getParameter("filename");
    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(new File("C:\\" + filename)));



    Kindly let me know any possible solution for this issue.

    Thanks in advance!
    Last edited by thenna; 08-27-2013 at 11:20 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: Servlet request.getParameter() always return null value

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. problème jsp servlets getParameter null
    By JohnSheppard in forum Java Servlet
    Replies: 0
    Last Post: 05-15-2013, 12:20 PM
  2. Replies: 1
    Last Post: 10-22-2011, 05:50 AM
  3. dynamically generation of request.getParameter()
    By ras_pari in forum New To Java
    Replies: 12
    Last Post: 05-21-2010, 11:12 AM
  4. Replies: 0
    Last Post: 03-10-2010, 02:52 PM
  5. Help with request.getParameter()
    By Albert in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 07-13-2007, 03:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •