0

Hello everyone this is code from my servlet. My task is to catch the elements from jsp page. For this I used req as a request attribute.

Now if I write fileItem = initRequest(req) to location 1 I am able to get my image but I am unable to catch the rest of the attribute like name, middlename, age etc. And if I write fileItem = initRequest(req) to location 2 I'm able to catch all the attribute like name, middlename, age etc. but I'm unable to get my image. But I want to perform both the tasks in the same code because I am not authorized to change the entire code.

This is my code…

//fileItem = initRequest(req); //location no 1
name=req.getParameter("name");
middlename=req.getParameter("middlename");
lastname=req.getParameter("lastname");
age=Integer.parseInt(req.getParameter("age")); 
gender=req.getParameter("gender");
email=req.getParameter("email");
mobno=req.getParameter("mobno");
religion=req.getParameter("religion");
nationality=req.getParameter("nationality");
username=req.getParameter("username");
password=req.getParameter("password");
rstatus=req.getParameter("rstatus");
//fileItem = initRequest(req);  //location no 2
File file = uploadFile(fileItem,"G://Friendbook//pictures");
Zong
  • 6,160
  • 5
  • 32
  • 46

0 Answers0