Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Getting session attributes from multipart/form-data form

 
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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • 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 VI Editor Redhat
  • 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.
 
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
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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