Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet getting dropdown values using apache commons in servlet

Have Programming Question? Ask it here!
 
 
 


aswinks
getting dropdown values using apache commons in servlet
0 Answer(s)      2 years and 3 months ago
Posted in : JSP-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>

Advertisement
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
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
javax.servlet.UnavailableException: org/apache/commons/chain/config/ConfigParser
javax.servlet.UnavailableException: org/apache/commons/chain/config/ConfigParser  Hi, i am anusha,when i am trying to run my struts program i got the fallowing exception: javax.servlet.UnavailableException: org/apache/commons
java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory Maven
java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory Maven  Hi, I am getting following error while running a maven based... dispatcher java.lang.NoClassDefFoundError: org/apache/commons/fileupload
java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory Maven
java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory Maven  Hi, I am getting following error while running a maven based... dispatcher java.lang.NoClassDefFoundError: org/apache/commons/fileupload
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
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
commons-upload.jar file placement - JSP-Servlet
commons-upload.jar file placement  Hi fren, Im still stucked at the jar file placment problem.. i'm still getting the same error "package... with "Apache tomcat 5.0"?? I've wasted a lot of time in this "file uploading
Set classpath and "commons-fileupload.jar" - JSP-Servlet
Set classpath and "commons-fileupload.jar"  Hi, Thanks... download the "commons-fileupload.jar" file.. but i'm not very sure where should i placed it.. I've tried placed it in my "C:\Program Files\Apache Software Foundation
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
reading dropdown values from properties file in jsp
reading dropdown values from properties file in jsp  reading dropdown values from properties file in jsp
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 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
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
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  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
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
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
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 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
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
How to get full path of the uploaded file using commons fileupload jar file
How to get full path of the uploaded file using commons fileupload jar... by using commons fileupload jar file or using other options? Its urgent. Thanks... of the security reasons, the browsers provide only the file name when using normal file
Java ftp commons
Java ftp commons  From should I download the Java ftp commons library. Thanks   Hi, Java ftp commons is actually Apache commons library... in Java for more information on how to use apache commons java ftp library
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
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
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
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
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
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
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
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
WEBSERVICE USING APACHE AXIS TUTORIAL-2
WEBSERVICE USING APACHE AXIS TUTORIAL-2 Accessing ejb-webservice  using  WAP (Wireles-Application Protocol) R.S.RAMASWAMY...;servlet>      <servlet-name>         ejbaxiswapservlet        <
Apache POI Excel Maximum Row - JSP-Servlet
Apache POI Excel Maximum Row  I am using Apache POI lib for export jsp results to excel file. I am getting error : Row number must be between 0... row value ? and How can I change that ? Thanks in advance Regards
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
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
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 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
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
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
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
dropdown
dropdown  how to hide textbox field when i deselect from select dropdown
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 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
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
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
Advertisements
 

 

 

DMCA.com