getting dropdown values using apache commons in servlet

Ads
 

getting dropdown values using apache commons in servlet

i want to get dropdown values in my program in order to merge the string to my file path so that the path will change dynamically according to user input.iam new to apache commoms,before that i was using o'reilly api.

here is my code :

 @Override
public void doPost(HttpServletRequest request, 
       HttpServletResponse response)
      throws ServletException, java.io.IOException 
{
   //FileItem f1;
String d1= request.getParameter("sel1");
String d2=request.getParameter("sel2");
String d3="/home/adapco/Desktop/output";
String conc=d3+"/"+d1+"/"+d2+"/";
filePath=(new StringBuilder()).append(conc).toString();
//      filePath="/home/adapco/Desktop/output/";
isMultipart = ServletFileUpload.isMultipartContent(request);
}

i tried to debug and i am getting the wright file path but while proceeding further,the fileItems shows size=0 and and it is not entering the loop because of size0.

filePath="/home/adapco/Desktop/output/";

if i pass the upload path to the filePath it works fine.

List fileItems = upload.parseRequest(request);    
Iterator i = fileItems.iterator();
while ( i.hasNext () ) 
{
 FileItem fi = (FileItem)i.next();
 if ( !fi.isFormField () )  
 {         
    String fieldName = fi.getFieldName();
    String fileName = fi.getName();
    String contentType = fi.getContentType();
    boolean isInMemory = fi.isInMemory();
    long sizeInBytes = fi.getSize();
    if( fileName.lastIndexOf("\\") >= 0 ){
       file = new File( filePath + 
       fileName.substring( fileName.lastIndexOf("\\"))) ;
    }else{
       file = new File( filePath + 
       fileName.substring(fileName.lastIndexOf("\\")+1)) ;
    }
    fi.write( file ) ;
    out.println("Uploaded Filename: " + fileName + "<br>"+filePath);

 }

my html :

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
 <title>File Uploading Form</title>
 </head>
<body>
<h3>File Upload:</h3>
 Select a file to upload: <br />
 <form action="upload" method="post"
                enctype="multipart/form-data">
 <input type="file" name="file">
 <br />
 <select name="sel1"> 
 <option label ="1">aerospace</option>
 <option label ="2">automotive</option>
 </select>
 <select name="sel2">
 <option label="1">internal</option>
 <option label="2">demo</option>
 </select>
 <input type="submit" value="Upload File" />
 </form>
 </body>
 </html>
View Answers

Ads









Related Tutorials/Questions & Answers:
getting dropdown values using apache commons in servlet
getting dropdown values using apache commons in servlet  i want to get dropdown values in my program in order to merge the string to my file path so that the path will change dynamically according to user input.iam new to apache
getting values from dropdown list
getting values from dropdown list  I am having a dropdown list which has hardcoded values ( we need it hardcoded only and will not be populated from... to the action. My action is getting called however, i am not sure how to pass
Advertisements
How to read a rows which have a values in a excel file using apache poi - JSP-Servlet
How to read a rows which have a values in a excel file using apache poi  Dear sir, How to read excel file in that only a rows which are having some values using apache poi...please help me sir. Thanks and Regards
Populate dropdown menu from database using jsp and servlet
Populate dropdown menu from database using jsp and servlet  please i need code to populate dropdown menu from mysql database using jsp and servlet. thanks
fetch values in dropdown
fetch values in dropdown  in my application i want fetch dropdown values in jsp page through servlet. means i have to fetch the database fields values in array variable of servlet and then i have to print those values in dropdown
inserting dropdown values into database table
inserting dropdown values into database table   hi i want to insert dropdown values into a database table by using jsp
how to load values of html form into an excel table using java servlet?
how to load values of html form into an excel table using java servlet?   i have written a java servlet program, which has a html form to be filled. after filling the form the servlet generates a receipt and the values should
Values from servlet into dropdownlist in jsp page using ajax
Values from servlet into dropdownlist in jsp page using ajax  1) jsp...); } } } Im not able to get values retrived from servlet into dropdownlist of jsp page...kindly check the code attached and tell me
Apache commons beanutils maven dependency
to another bean using the Apache Commons BeanUtils class.   Check...Apache commons beanutils maven dependency  How to use the Apache...;/version> </dependency> Thanks   What is Apache Commons BeanUtils
reading dropdown values from properties file in jsp
reading dropdown values from properties file in jsp  reading dropdown values from properties file in jsp
store dropdown box values in database server
store dropdown box values in database server  how to store dropdown box values in database server in jsp
Getting image pixel values
Getting image pixel values  how to get image pixels values on mouse click   import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; import java.io.*; import javax.swing.*; public class
Maven dependency for Apache Commons
functionality where I have to use Apache Commons library in pom.xml file. What is Maven dependency for Apache Commons? I just need dependency code to be added to pom.xml file. Thanks   Hi, The Apache Commons is a project under
getting and storing dropdown list in database in jsp
getting and storing dropdown list in database in jsp  i have a drop down list to select book from database. i'm able to retrieve dropdown list from... into data(language) values('"+selectedValue+"')"); out.println("Data
Getting an exception - JSP-Servlet
Getting an exception  Dear Sir , While sending a mail am getting an following exception javax.mail.MessagingException: 554 mail server permanently rejected message (#5. 3.0)so how to over come from this please help
Apache Commons ioutils maven dependency
Apache Commons ioutils maven dependency  Hi, What is the maven dependency of Apache Commons ioutils? I want to use this for my project which...: Apache Commons ioutils maven dependency <dependency> <groupId>
Getting data from servlet into javascript
Getting data from servlet into javascript  How do i get json data from my servlet on to a variable in javascript n bind the data to display onto sigma grid.Has anyone Idea how to do
jsp dropdown refresh - JSP-Servlet
jsp dropdown refresh  Sir Thank u for your jsp code for dependent dropdown list, i used it in different table for data extraction but the probleam during data extraction when i select first drop down its refresh then 2nd
Inserting values into a database table of selected DropDown in jsp.
Inserting values into a database table of selected DropDown in jsp.  http://www.roseindia.net/answers/viewqa/Ajax/15250-DropDown-in-ajax+jsp.html... to insert all selected values in data base correspondent to each like if user
Example of Getting request URL in a servlet
Example of Getting request URL in a servlet  One servlet can be configured to handle a set of requests. So, in Servlet you have to get the URL of the page accessed. How you can get the URL of the page accessed in the Servlet
jsp -sevlet connecting to database using dropdown
jsp -sevlet connecting to database using dropdown  How can I get my dropdown list from oracle database and then submit it to another table in JSP. I am thinking of a form that links to a servlet and the servlet connects
i am getting multiple values in listbox
i am getting multiple values in listbox   hi sir, i am using msaccess 2007.my query is look like this. select distinct a.name,b.fee from... getting its working fine, but in main query also i am getting multiple name
apache commons io 2.6 maven
apache commons io 2.6 maven  Hi, What is maven dependency of apache commons io 2.6 maven? Which code i should add in pom.xml to add apache commons io 2.6 in maven project? Thanks   Hi, Apache commons io library
apache commons io 2.6 maven
apache commons io 2.6 maven  Hi, What is maven dependency of apache commons io 2.6 maven? Which code i should add in pom.xml to add apache commons io 2.6 in maven project? Thanks   Hi, Apache commons io library
apache commons io 2.6 maven
apache commons io 2.6 maven  Hi, What is maven dependency of apache commons io 2.6 maven? Which code i should add in pom.xml to add apache commons io 2.6 in maven project? Thanks   Hi, Apache commons io library
How to add Apache Commons IO in pom.xml file?
How to add Apache Commons IO in pom.xml file?  Hi, How to add the dependency of the Apache Commons IO library in the pom.xml file in a Java project? My Project is using the maven for dependency management and compilation
3 dropdown list from the database using JSP
3 dropdown list from the database using JSP  Hi, I'm new to JSP I want to create 3 dropdown list each depend on the other and get the options from the database using JSP
apache tomcat problem - JSP-Servlet
-tomcat-6.0.18\;" instead of using "CATALINA_HOME=C:\apache-tomcat-6.0.18\bin...apache tomcat problem  hi, i am trying to run apache tomcat...=C:\apache-tomcat-6.0.18\bin\; JAVA_HOME="C:\Program Files\Java\jdk1.6.0_05\bin
apache commons fileutils maven dependency
apache commons fileutils maven dependency  Hi, I am writing a program to for directory listing and want to add apache commons fileutils maven... to get apache commons fileutils maven dependency in my project. Thanks   
apache commons fileutils maven dependency
apache commons fileutils maven dependency  Hi, I am writing a program to for directory listing and want to add apache commons fileutils maven... to get apache commons fileutils maven dependency in my project. Thanks   
apache commons fileutils maven dependency
apache commons fileutils maven dependency  Hi, I am writing a program to for directory listing and want to add apache commons fileutils maven... to get apache commons fileutils maven dependency in my project. Thanks   

Ads