Kapil
Kapil

Reputation: 350

how to take jsp textbox value to java class file?

Hello i use jsp file and i write following code in jsp file.

 <aui:form name="fm" method="POST" action="<%= updateTestiURL.toString() %>"  
  enctype="multipart/form-data">
  <aui:input name="subject" label="Subject"/>
  <aui:input type="file" name="fileName"/>

using this i can upload file successfully with my java file. but when i try to get text box value it returns null. i write following code in java to get text box.

    subject=(String)actionRequest.getParameter("subject");  

If i remove following

 enctype="multipart/form-data"

from jsp file then i can get value of text box, but another problem generate.I cant upload file. Kindly tell me how to get both ?

Upvotes: 0

Views: 797

Answers (1)

NilsH
NilsH

Reputation: 13821

When the enctype is multipart/form-data, the request needs to be parsed as a multipart request. There are several libraries available for that task, e.g. Commons File Upload

Upvotes: 2

Related Questions