How to get multiple selections from jsp page in my servlet

Hello Everyone,
I've a list that allows users to make multiple selections.
<select name=location multiple="multiple">
    <option>
         All
    </option>
    <option>
         Hyd
    </option>
    <option>
         Dub
    </option>
    <option>
         Mtv
    </option>
  </select>I want to get the selections made by user in jsp page from my servlet, selections can be multiple too.
ArrayList locList = new ArrayList();
locList = request.getParameter("location");when I do so, I get compilation error as the request returns string type. How do I then get multiple selections made by the user.
Please let me know.

For those kind of basic questions it would help a lot if you just gently consult the javadocs and tutorials.
HttpServletRequest API: [http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html]
Java EE tutorial part II: [http://java.sun.com/javaee/5/docs/tutorial/doc/]
Coreservlet tutorials: [http://courses.coreservlets.com/Course-Materials/]

Similar Messages

  • How to get multiple selected fields in list

    Hello all,
    I am trying to get multiple selected value from a list but i dont know how to get multiple selected fields from a list though AS3.
    Actually i want to pass the selected fields to php, so for that i need to get the selections and send to php.
    Thankx..

    i want to put the selected fields of list in an array through AS3....
    actually......i figured it out how to do that...........
    Its simple......use
    list.selectedItems[index]
    and to get the number of items selected......
    list.selectedItems.length
    simple.....

  • How to get attribute value from standard page ?

    Hi,
    How to get attribute value from standard page ?
    String str = (String)vo.getCurrentRow().getAttrbute("RunId");
    But this value is returning a null value ....
    Can anyone help me to get this attribute value which is actually having a actual value .

    getCurrentRow() would always return null if no setCurrentRow() is used.
    Please check the page design and understand how many rows of VO are there. You can also use the following to get the row:
    vo.reset();
    vo.next();
    Regards
    Sumit

  • How to load java class from jsp page?

    hi all!
    Does anyone know how to load java class from jsp page?
    I try to load java class from jsp page.
    Is it possible to load java class fom jsp page?
    thanks and have a good day!

    What I mean is How to load/open java class file from jsp page?
    I think we can open Applet from jsp page by using
    <applet code=helloApplet.class width=100 height=100>
    </applet>
    but, how to open java class which is an application made by Frame?
    thanks and have a good day

  • How to get multiple values from the list

    I've a list of an item which I queried it from the database. I also created a button that will takes a selected items from the list when it was clicked. I used javabean to get the data from database.
    <%     // clicked on Select District Button
    Vector vselectedDistrict = new Vector();
    Vector vdistrictID = new Vector();
    String tmpSelectDistrict = "";
    tmpSelectDistrict = request.getParameter("bSelectDistrict");
    if(tmpSelectDistrict != null)
         // get multiple values from the list
         String[] selectedDistrict = request.getParameterValues("usrTDistrict");
         vselectedDistrict.clear();
         vdistrictID.clear();
         if((selectedDistrict != null) && (selectedDistrict.length != 0))
                             for(int i=0;i<selectedDistrict.length;i++)
                   vselectedDistrict.addElement(selectedDistrict);           
              vdistrictID = dbaseInfo.getcurrentDistrictID(nstate,vselectedDistrict);
              for(int i=0;i<vdistrictID.size();i++)
                   out.println("district = " + selectedDistrict[i]);                         out.println("district ID= " + vdistrictID.get(i).toString());
    %>
    // get vdistrict from the database here......
    <select name="usrTDistrict" size="5" multiple>
    <%     for(int i = 0; i< vdistrict.size(); i++)
    %>
         <option value="<%=vdistrict.get(i).toString()%>"><%=vdistrict.get(i).toString()%></option>
    <%
    %>          
    </select>
    <input type="submit" name="bSelectDistrict" value="Select District">
    Lets say the item that i selected from the list is 'Xplace' and I clicked on the Select District button,
    what I got is this error message:
    org.apache.jasper.JasperException: Unable to convert string 'Xplace' to class java.util.Vector for attribute usrTDistrict: java.lang.IllegalArgumentException: Property Editor not registered with the PropertyEditorManager
    So where is going wrong and what the message means?. Any help very much appreciated. Thanks

    These are just guesses that might hopefully steer you in directions you haven't looked in yet.
    I presume you used triangle brackets (< >) to avoid having the Jive Forum think it was the "italics" tag?
    Are you certain this: dbaseInfo.getcurrentDistrictID(nstate,vselectedDistrict);
    expects a Vector as its second parameter? And returns a Vector?
    I don't believe you've shown how you use the javabean, or its code? Perhaps it should be rewritten to accept an array of strings instead of a Vector?

  • Unable get complete filepath from jsp page using request.getParameter()

    Hey all,
    i am actually trying to get the selected file path value using request.getParameter into the servlet where i will read the (csv or txt) file but i dont get the full path but only the file name(test.txt) not the complete path(C:\\Temp\\test.txt) i selected in JSP page using browse file.
    Output :
    FILE NAME : TEST
    FILE PATH : test.txt
    Error : java.io.FileNotFoundException: test.txt (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileReader.<init>(FileReader.java:55)
    at com.test.TestServlet.processRequest(TestServlet.java:39)
    at com.test.TestServlet.doPost(TestServlet.java:75)
    JSP CODE:
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>DEMO SERVLET</title>
    </script>
    </head>
    <body>
    <h2>Hello World!</h2>
    <form name="myform" action="TestServlet" method="POST"
    FILE NAME : <input type="text" name="filename" value="" size="25" /><br><br>
    FILE SELECT : <input type="file" name="myfile" value="" width="25" /><br><br>
    <input type="submit" value="Submit" name="submit" />
    </form>
    </body>
    </html>
    Servlet Code :
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException, FileNotFoundException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
    String filename = request.getParameter("filename");
    out.println(filename);
    String filepath = request.getParameter("myfile");
    out.println(filepath);
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet TestServlet</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");
    if (filepath != null) {
    File f = new File(filepath);
    BufferedReader br = new BufferedReader(new FileReader(f));
    String strLine;
    String[] tokens;
    while ((strLine = br.readLine()) != null) {
    tokens = strLine.split(",");
    for (int i = 0; i < tokens.length; i++) {
    out.println("<h1>Servlet TestServlet at " + tokens[i] + "</h1>");
    out.println("----------------");
    out.println("</body>");
    out.println("</html>");
    } finally {
    out.close();
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    Needed Output :
    FILE NAME : TEST
    FILE PATH : C:\\Temp\\test.txt
    Any suggestions Plz??

    As the [HTML specification|http://www.w3.org/TR/html401/interact/forms.html] states, you should be setting the enctype to multipart/form-data to be able to upload files to the server. In the server side, you need to process the multipart/form-data binary stream by parsing the HttpServletRequest#getInputStream(). It is a lot of work to get it to work flawlessly. There are 3rd party API's around which can do that for you, such as [Apache Commons FileUpload|http://commons.apache.org/fileupload] (carefully read the User Guide how to use it).
    You can also consider to use a Filter which makes use of the FileUpload API to preprocess the request so that you can continue writing the servlet code as usual. Here is an example: [http://balusc.blogspot.com/2007/11/multipartfilter.html].

  • How to get multiple rows from database table?

    hello !
    I need to get multiple rows from a OLEDB database table and display them on a table object.
    I did "Wrap in subfrom" on the table,  set  subform of the table to "flowed", and checked "Repeat row for each data item" of Row1 of the table.
    But I can get only one row on the table object.
    I need your help.
    Thanks

    Hi,
    best practices when deleting multiple rows is to do this on the business service, not the view layer for performance reasons. When you selected the rows to delete and press submit, then in a managed bean you access thetable instance (put a reference to a managed bean from the table "binding" property") and call getSeletedRowKeys. In JDeveloper 11g, ADF Faces returns the RowKeySet as a Set of List, where each list conatins the server side row key (e.g. oracle.jbo.Key) if you use ADF BC. Then you create a List (ArrayList) with this keys in it and call a method exposed on the business service (through a method activity in ADF) and pass the list as an argument. On the server side you then access the View Object that holds the data and find the row to delte by the keys in the list
    Example 134 here: http://blogs.oracle.com/smuenchadf/examples/#134 provides you with the code
    Frank

  • How to get multiple records from internal table through BDC

    PERFORM DYNPRO USING:
      'X'  'SAPMM61L'  '0500',
      ' '  'BDC_OKCODE'  '=NEWC',
      'X'  'SAPMM61L'  '0500',
      ' '  'BDC_CURSOR'  'PLPTU-PLWRK(01)',
      ' '  'BDC_OKCODE'  '=TAKE',
      ' '  'PLPTU-PLWRK(01)' '2531'. (2531 is a plant)
    This is the recording used to get plant via BDC of MS31.
    Using this code i can get only single plant...
    If i want to get multiple plants from an internal table,how i can change this code?
    Since it is a recording i cant put this code in LOOP..ENDLOOP.
    Suggest any method for doing this....
    Awaiting for ur reply...

    Hi,
    While recording also record the scroll down button.
    The you can place different plant in the BDC using loop and endloop
    Regards
    Arun

  • How to call RDF report from JSP page

    Dear all,
    I want to call a RDF report from JSP page. I am creating the JSP page using j developer 10G.
    Can anyone help me out in this case. Is there any tag or procedure or any other way by of that i can perform this work.
    please help and send the reply on [email protected],[email protected]
    thanks
    Ashok

    Hi Ashok,
    You can use rwservlet - nothing really to do with JDeveloper. Once you have report server up and running (hint: read http://download-uk.oracle.com/docs/cd/B14099_19/bi.1012/b14048/toc.htm), you can call a report like this:
    http://server:port/rwservlet?report=my_report.rdf&destype=cache&desformat=html&p_my_parameter=xxx etcHope this helps,
    John

  • Q. How to get multiple results from a single column in a recordset using PHP

    Hi everyone
    Hope someone can help. I have a column called categories and about 5 categories listed. I want to show all products that are listed in say 2 categories. I only have basic php skills so only know how to pass a url value to show the products from 1 category e.g. 
    Select *
    FROM product
    WHERE category = colname
    $colname = $_GET['category'];
    URL...page.php?category=fruit
    Questions is how do I get the products from multiple categories to show e.g. all products from categories 'fruit', 'dairy', 'meat'
    Your help will be much appreciated as I am getting tired of beating my head against the wall. (should invent a PHP wall pillow and sell it online)
    Thanks

    $colname1 = $_GET['category1'];
    $colname2 = $_GET['category2'];
    $colname3 = $_GET['category3'];
    Select *
    FROM product
    WHERE category IN  ('$colname1', '$colname2', '$colname3')
    >Your help will be much appreciated as I am getting tired of beating my head against the wall
    My guess is that you are trying to build a web application without having first learned the basics on PHP and SQL. That's certainly the hard way.

  • How to get Tree structure in JSP page?

    Hi,
    I would like get data from the database and display the data in tree structure with the check boxes at each nodes on a jsp page with out using any third party tools. how can i do that? Do i require any new tags to fulfill this requirement?
    can any one help me out by sending any example code?
    thanks in advance.
    Regards,
    Reddy

    Once you have the data in a list or something, can't you just use <c:forEach> and then output standard nested <ul> and <li> tags to give the tree structure.
    <html>
         <style>
              li
                   list-style-type:none;
         </style>
         <body>
              <form>
                   <ul>
                        <li>
                             <input type="checkbox">Check 1</input>
                             <ul>
                                  <li>
                                       <input type="checkbox">Check 1A</input>
                                  </li>
                                  <li>
                                       <input type="checkbox">Check 1B</input>
                                  </li>
                             </ul>
                        </li>
                        <li>
                             <input type="checkbox">Check 2</input>
                             <ul>
                                  <li>
                                       <input type="checkbox">Check 2A</input>
                                  </li>
                             </ul>
                        </li>
                        <li>
                             <input type="checkbox">Check 3</input>
                        </li>
                   </ul>
              </form>
         </body>
    </html>

  • How to perform multiple selection from dropdown list

    Hi,
           I have developed one application in which i have taken one dropdownbyindex and entered some values in it, now i need to have multiple selection of entries, can any one please suggest how to do these
    Regards,
    Prasanna

    A drop-down list is by definition a 1-from-many selector.
    Armin

  • How to get the select * from emp table output on the console  using java

    public class software {
          * @param args
         static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
         static final String DATABASE_URL = "jdbc:oracle:abc";
         private static Connection connection;
         private static Statement statement;
         public static void main(String[] args) {
              // TODO Auto-generated method stub
         try {
              System.out.println("-------THIS IS THE Class.forNameJDBC_DRIVER");
                   Class.forName(JDBC_DRIVER);
                   System.out.println("THIS IS THE Class.forNameJDBC_DRIVER");
                   connection = DriverManager.getConnection(DATABASE_URL, "abc",
                   "abc");
                   System.out.println("THIS IS THE connection abc ,abc");
                   statement = connection.createStatement();
                   //Query to find the values in the EMP table.
                   ResultSet resultSet = statement.executeQuery("SELECT * from EMP");
                   if(resultSet.next()){
                   System.out.println("THESE ARE THE VALUES IN EMP TABLE:"+resultSet);  /// How can i get all the values record wise on the  console ??????
                   resultSet.close();
         catch (ClassNotFoundException classNotFound) {
                   System.out.println("Driver not Found"+classNotFound.getMessage());
              } catch (SQLException sqlException) {
                   System.out.println("SQL Exception - bad sql");
                   System.out.println(sqlException.getMessage());
    }

    1sai
    Please assign the dukes here and in your previous threads.
    See [http://wikis.sun.com/display/SunForums/Duke+Stars+Program+-+How+it+Works]
    You are currently the all time career leader in un-awarded dukes, with including this thread 75 unawarded dukes for questions you marked as answered.
    It's even worse when you look and see that you have awarded many dukes as well. So you do know how to do it. You're just too lazy and rude to be bothered.
    Don't be a lazy wank.

  • How to get ep authority in jsp page

    Hi all:
    I want to create a j2ee project and some jsp pages to deploy to EP server.
    My question is how to get user name or user authority in jsp page.
    Is there any APIs to use or something else.
    Thanks in advance.
    Allen

    Hai ,
    I Think  This will help ful for u check it ,
    File=new FileLog("f:/WebServiceTrace/trace2.%g.log", 800000, 10,                                        new  TraceFormatter());
    The above code specifies the path for your log file.
    Then add this file as a log location and then log the traces. For this you can use the following code like:
    Location location=Location.getLocation(className);
              location.addLog(file);
              location.setEffectiveSeverity(Severity.ALL);
              location.entering(methodName);
    To Create j2ee apllication
    In path new-j2ee-jsp to create JSP's can only be used for J2EE applications.
    So as you are using this in Portal Application, this does not work.
    You can test this bahavior by creating a new Web Application (New-Project-J2EE-Web Module Project)
    In this Web Module Project, try creating JSP, this will work.
    So dont use new-j2ee-jsp to create JSP in Portal Application instead use New-File and name the file as jsp.
    Regards ,
    venkat

  • How to get table headers in jsp page

    hi,
    this is praveen, can any one help me to solve this problem.
    how to get table headers in a jsp page. whether it is possible using javascript or is there any other way.
    pls send rep.
    thank u.

    Hai ,
    I Think  This will help ful for u check it ,
    File=new FileLog("f:/WebServiceTrace/trace2.%g.log", 800000, 10,                                        new  TraceFormatter());
    The above code specifies the path for your log file.
    Then add this file as a log location and then log the traces. For this you can use the following code like:
    Location location=Location.getLocation(className);
              location.addLog(file);
              location.setEffectiveSeverity(Severity.ALL);
              location.entering(methodName);
    To Create j2ee apllication
    In path new-j2ee-jsp to create JSP's can only be used for J2EE applications.
    So as you are using this in Portal Application, this does not work.
    You can test this bahavior by creating a new Web Application (New-Project-J2EE-Web Module Project)
    In this Web Module Project, try creating JSP, this will work.
    So dont use new-j2ee-jsp to create JSP in Portal Application instead use New-File and name the file as jsp.
    Regards ,
    venkat

Maybe you are looking for

  • IPhone won't mount on MacBook Pro

    Has awlays mounted via USB port no problem until a couple of days ago. MacBook does not see the iphone when connected via USB, and the iphone will not charge. iPhone will charge when connected to AC power. iphone does not show up in System Profiler.

  • AuditWorkflowService Not Working Correctly

    Hello, We have been using Record & Playback to record most of our processes and it has recently stopped working correctly.  Processes were no longer going through and forms would hang when trying to open them.  When trying to play process recordings

  • *** Instance Number already in use. ***

    Hi, if I start my oracle collaboration suite services, I get the following message after "Starting the Monitor process.": *** Instance Number already in use. *** *** Please try a different Instance number. *** Why? And after this (ldapcheck): Checkin

  • Change RFQ & PO output from fax to e-mail

    Change RFQ & PO output from fax to e-mail

  • Add a Component visually on a complete simple javabean

    Hi all! I wrote a simple javabean(jPanel, on this panel i have 1 jButton and some JLabels) in Netbeans. I can use and display this Javabean in Netbeans(5 and 6). But i cant add visually an Component(like jButton) on the javabeans. the Components are