Request.getparameter returns null in jsp

1,389 views
Skip to first unread message

Lukman Jaji

unread,
Nov 23, 2015, 3:46:21 PM11/23/15
to CodenameOne Discussions
Hi all

I have a multipart request connection which i have created thus...

                    MultipartRequest request = new MultipartRequest();
                    request
.setUrl(AppConstants.SAVE_URL);
                    request
.setPost(true);
                    request
.addArgumentNoEncoding("entry_name", entry.trim());
                    request
.addData("entry", dir + sep + "sent" + sep + "sent.jaji", "jaji");
                    request
.setFilename("content", "sent.jaji");
                   
InfiniteProgress inf = new InfiniteProgress();            
                   
Dialog progress = inf.showInifiniteBlocking();
                    request
.setDisposeOnCompletion(progress);
                   
NetworkManager.getInstance().addToQueue(request);

On my server side

<%
   
String entry_name = request.getParameter("entry_name");
   
System.out.println("entry name is  "+entry_name);
%>

The entry name is always null.... I checked the network monitor and here is what it has

-15135fd3821
Content-Disposition: form-data; name="entry_name"
Content-Type: text/plain; charset=UTF-8

Nigeria_Data
--15135fd3821
Content-Disposition: form-data; name="entry"; filename="entry"
Content-Type: jaji


The result i expect should be Nigeria_Data but I get null instead. Kindly assist.

Regards

Shai Almog

unread,
Nov 23, 2015, 11:37:22 PM11/23/15
to CodenameOne Discussions
Hi,
not sure what sep is. Multipart already handles the separator of entries.
Why are you using the no encoding variant of the add argument?

Lukman Jaji

unread,
Nov 24, 2015, 3:17:28 AM11/24/15
to CodenameOne Discussions
Hi Shai

sep is the device separator...
I used addArgumentNoEncoding() because even the regular addArgument() still gave the null result. I had thought the encoding was a problem.

However, my server side cos i getting only the entry_name and sep shouldn't be a problem.? I stand to be corrected.

Lukman

Shai Almog

unread,
Nov 24, 2015, 11:00:48 PM11/24/15
to CodenameOne Discussions
Hi,
do you mean the multi-part separator?
That's already encoded into the multipart request code so having your own separator would conflict with that.

Lukman Jaji

unread,
Nov 27, 2015, 7:10:29 PM11/27/15
to CodenameOne Discussions
Hi Shai

I think I found the problem and it has nothing to do with the separator because I commented out the code for adding files or data to the request. I just passed an argument to the request and I still get null on the server side.

On the other hand, if I changed to ConnectionRequest, i get the correct value on the server side.

                    MultipartRequest request = new MultipartRequest();
                    request
.setUrl(AppConstants.SAVE_URL);
                    request
.setPost(true);

                    request
.addArgument("entry_name", entry.trim());

                    InfiniteProgress inf = new InfiniteProgress();            
                    
Dialog progress = inf.showInifiniteBlocking(); 
                    request
.setDisposeOnCompletion(progress);
                    
NetworkManager.getInstance().addToQueue(request);



This still does not work but if I changed to ConnectionRequest, it works perfect.

What could be wrong?

Regards

Shai Almog

unread,
Nov 28, 2015, 12:17:02 AM11/28/15
to CodenameOne Discussions
Hi,
if this works it means your server code isn't a multipart server. You need to fix the server.
I'm not familiar with PHP but multipart is very different to standard post.

Lukman Jaji

unread,
Nov 30, 2015, 1:52:23 AM11/30/15
to CodenameOne Discussions
Hi Shai

I am using JSP and not PHP....and my server is glassfish...any tips on how to make it accept multipart requests? This is the first time I'm experiencing this..

Shai Almog

unread,
Nov 30, 2015, 11:52:19 PM11/30/15
to CodenameOne Discussions

Lukman Jaji

unread,
Dec 31, 2015, 4:52:28 AM12/31/15
to CodenameOne Discussions
Thanks Shai...I got it to work even though I still used JSPs...

I used the Orielly Servlets Multipart and I am able to access parameters and attachments...

Thanks
Reply all
Reply to author
Forward
0 new messages