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 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









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
getting values from database - JSP-Servlet
getting values from database  I tried the following code abc.html aaa.jsp I am not getting exceptions now. But I am not getting output also. Plz help.   Hi Friend, Run your
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
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
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
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
count values using jsp - JSP-Servlet
count values using jsp  hai deepak i have a query i am dynamically generating textbox with names in that i am having headings and subheadings i want to get the count of textboxes which are heading under that how
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
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
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
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
How to store values in a database using JSTL? - JSP-Servlet
How to store values in a database using JSTL?  I want to store values... extract details and displays in a table format... Now i want to store these values... in database using JSTL name number Position add
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
jsp dropdown - JSP-Servlet
jsp dropdown  print dropdown selected value in same page without refreshing page in jsp....   Hi Friend, Try the following code: 1... to use this textbox value to fetch values from database
dropdown - JSP-Servlet
dropdown  i want to use dropdown select value in query-string in same page.. Using selected 'name' want to fetch details of that person from database.. without using Ajax...  Hi Friend, Try the following code
jsp dropdown - JSP-Servlet
jsp dropdown  in my table there are 3 fields named orderid ,itemname, itemqty. i want code that fetch orderid in dropdown... on select dropdown get all items list of that orderid... there are multiple items at one orderid
dropdown - JSP-Servlet
dropdown  i want to use dropdown select value in query-string in same page.. Using selected 'name' want to fetch details of that person from database..  Hi Friend, Try the following code: 1)ajaxExample.jsp
dropdown - JSP-Servlet
dropdown  i have below code for dropdown . now i want to user that textbox value in query at same page... how to get it in a new variable??? function getValue(){ var combo = document.getElementById("sel"); var val
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
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
Not getting the logic - JSP-Servlet
Not getting the logic  there is one sub module in my project.In that it display the list of candidates in a grid table who are selected... to get those selected checkbox values to send mail to selected candidates
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
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
Getting an exception - JSP-Servlet
Getting an exception   sir i am Getting following exception when executing javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/POIFSFileSystem I have used ur code import
Getting an exception - JSP-Servlet
Getting an exception  thanks sir for u r reply ,but i already added that jar file sir even though i m getting an exception sir please help me sir ... thanks in advance..  Hi Friend, You can do one thing, replace
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
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
Getting an exception - JSP-Servlet
Getting an exception  sir i used u r code for sending a mass email by reading an excel sheet,but i am getting a following error so please help me if any changes in code . thanks in advance.. java.io.IOException: Invalid
Getting an exception - JSP-Servlet
Getting an exception  sir i used u r code for sending a mass email by reading an excel sheet,but i am getting a following error so please help me if any changes in code . thanks in advance.. java.io.IOException: Invalid
Getting an exception - JSP-Servlet
Getting an exception  Dear sir,while executing this code i am getting a following error ,i am sending my code also please help me sir... //following is a code int a = 0, b = 1, c = 2, d = 3, e = 4,f=0; //int a, b, c, d, e
Getting an exception - JSP-Servlet
Getting an exception  sir i m Getting an following exception while sending a mail with attachment value ofsession is javax.mail.Session@192d604 value of mimemessage is javax.mail.internet.MimeMessage@120b2da value
Getting an exception - JSP-Servlet
Getting an exception  sir i changed to that ie InputStream myInput1 = new FileInputStream(fileName); HSSFWorkbook myWorkBook = new HSSFWorkbook(myInput1); but when i click on a browse button and attached a file
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
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
How to change the dropdown values based on other dropdown in itext pdf or in any other?
How to change the dropdown values based on other dropdown in itext pdf or in any other?  How to change the drop down values based on another drop down? For eg: If we select one county, that related states only come, if we select
retrive values - JSP-Servlet
retrive values  how to get multiple values from html to jsp
creating list in dropdown using struts - Struts
creating list in dropdown using struts   creating list in dropdown using struts : In action class list.add(new LabelValueBean("ID","Name")); In Jsp * Select Item Select In Form : getter
getting error while inserting values in database
getting error while inserting values in database  AddUser.java... into LTCINFO.PERSONS values ('"+LASTNAME+"','"+FIRSTNAME+"','"+ADDRESS+"','"+CITY... followin error i don't know why "ORA-00947: not enough values". kindly chk
previous values in servlet - JSP-Servlet
previous values in servlet  Hi... I've an application where there are two links link1 and link2 when i clicked link1 there's a form with relevant... to the link1 after link2 the same values are still in the form... How to remove
How to Fetch Data using dropdown option
How to Fetch Data using dropdown option   sir maine jsp pr ek login page banaya jismain branch ka option hai. main agar first dropdown main first year branch select karta hoon to first year ki sari branches ki list second drop
retrive values - JSP-Servlet
retrive values  how to retrive multiple values from html to jsp  Hi Friend, Try the following code: 1)calljsp.html: Enter Name: Enter Address: Gender:MF Qualification: Btech MBA MCA MSC
insert values - JSP-Servlet
insert values  How to insert values in the oracle database using JSP. Plz tell the core answer as soon as possible .  HiThis is html...;insert user_details values('"+username+"','"+jobposition+"
passing values - JSP-Servlet
=null; /*Inserting Name,Hallno:,Time,Date,Mobileno: details using method..._DataInsertion(Name,Hallno,Time,Date,Mobileno,Status) values('"+name+"','"+hallno+"','"+time
Dynamically display values in dropdown box and then show the selected values as selected by the user which is already stored in the DB
Dynamically display values in dropdown box and then show the selected values... this code it is adding one more value to the dropdown box and showing as selected. so if I have 5 values in the dropdown this selected one is added as 6th values
how to load value in dropdown list after selecting value from first dropdown list using javascript
how to load value in dropdown list after selecting value from first dropdown list using javascript  how to load value in dropdown list after selecting value from first dropdown list using javascript
How to carry multiple values from a Servlet to a JSP?
How to carry multiple values from a Servlet to a JSP?  By using...). ----response.sendRedirect("index.jsp?uname="+username);---- But I want multiple values needs to be carried from my servlet to a JSP. How do I do
Getting ResultSet size - JSP-Servlet
Getting ResultSet size  Hello friends, what is the result getFetchSize() of resultset. I got error with this method. While rs contains three rows it returns 0 . Please help me.  Hi friend
problem getting servlet:xmlHTTP.status=404 - Ajax
problem getting servlet:xmlHTTP.status=404   hi, ihave a text field... of the servlet, it gets it and teh xmlHTTP.status =404 condition becomes false.im using... object.The problem is my script is unable to get the servlet in which i have

Ads