Bookmark Topic Watch Topic
  • New Topic

Getting session attributes from multipart/form-data form

 
Ramesh kangamuthu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,
I have been doing a web application related on online shopping. It has file uploading capability.In some forms,I used enctype="multipart/form-data" for the forms. I set some session attributes in the jsps,in which I put enctype as multipart/form-data for the forms. If I tried to get the session attributes in servlets, I got null. How can I retrieve session and other types of attributes from jsps?

Can anyone give me the answer?

Best regards,

Ramesh Kanagamuthu
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
I think you're either confusing terms or misinterpreting the problem you're seeing.

I don't think the problem is with the adding or retrieving of variables to or from session. It's most likely that you're not getting the parameters properly. When you respond to multipart requests in your servlets or JSPs, request.getParameter doesn't work. It will always return null.
To retrive your form parameters, you'll need to check the documentation for the upload libraries that you're using.
 
Ramesh kangamuthu
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks Ben,

I understood the problem clearly. In multipart request request.getParameter() does not work,I knew. Also I got those type of parameters after checking FileItem's isFormField() method and

fileItemObject.getName()

fileItemObject.getString() methods. No problem.

My problem is how I can get session attributes set in a jsp,that has multipart/form-data form. I tried for the multipart form and got the session attribute as null. If the request is not multipart, result comes.

If I tried the following

NewsList newsList=(NewsList)request.getSession().getAttribute("newsList");

I got the newsList Object as null. This is not null If I try with non-multipart request.

Best Regards,
Ramesh Kangamuthu
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Can you post the code that sets the session variables?
Also describe the flow of your application so we know when each component is executed.
 
sridhar chinchili
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Ramesh,

I am also facing the same issue, have you resolved this? Please share me how to fix this issue.

Regards,
Sridhar
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please start a new topic rather than piggy-backing on this old one. And clearly explain your issue.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!