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



Home Answers Viewqa JSP-Servlet Retriving value from dropdown list nad disply it in other page

Have Programming Question? Ask it here!
 
 
 


pradeep naidu
Retriving value from dropdown list nad disply it in other page
5 Answer(s)      3 years and 8 months ago
Posted in : JSP-Servlet


Hello,

I have a dropdownbox on my webpage and a map which contains a marker, and that marker contains a button, on click of that button i need to get the name of the selected value from the dropdown list and dispaly it to on the next page.

i used request.getParameter("") but its not working its printing "null".

So could you please help me out with this!!

thanks, Pradeep


Advertisement
View Answers

January 13, 2011 at 12:44 PM


Hi Friend,

Try this:

1)combo.jsp:

<html>
<form method="post" action="selectedValue.jsp">
Select Programming Language:
<select name="lang">
<option value="C/C++">C/C++</option>
<option value="C#">C#</option>
<option value="Java">Java</option>
<option value="Perl">Perl</option>
<option value="Python">Python</option>
</select><br>
<input type="submit" value="Submit"><br>
</form>
</html>

2)selectedValue.jsp:

<%
String selectedValue=request.getParameter("lang");
out.println("Selected Value is: "+selectedValue);
%>


January 13, 2011 at 12:44 PM


Hi Friend,
Try this:

1)combo.jsp:

<html>

<form method="post" action="selectedValue.jsp">
Select Programming Language:
<select name="lang">
<option value="C/C++">C/C++</option>
<option value="C#">C#</option>
<option value="Java">Java</option>
<option value="Perl">Perl</option>
<option value="Python">Python</option>
</select><br>
<input type="submit" value="Submit"><br>
</form>

</html>

2)selectedValue.jsp:

&lt;%
String selectedValue=request.getParameter("lang");
out.println("Selected Value is: "+selectedValue);
%&gt;


January 13, 2011 at 2:07 PM


but my problem is i have the button on my marker and the dropdownlist is on the webpage so how to link both button and dropdownlist

can u please help me on this issue



January 14, 2011 at 3:21 PM


Hi Friend,

Post your code.

Thanks



January 17, 2011 at 11:45 AM


ok iam posting my code

This is my 1.jsp file

<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.sql.*" %>

        <%!
            int i=1;
            Connection connection = null;
            boolean foundResults = false;
            ResultSet set = null;
            Statement statement = null;
            String city;
            String ip;
            String sysname;
            String sess;

        %>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> 

  <head> 

    <meta http-equiv="content-type" content="text/html; charset=utf-8"/> 

    <title>Google Maps API Sample</title>

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAPDUET0Qt7p2VcSk6JNU1sBSM5jMcmVqUpI7aqV44cW1cEECiThQYkcZUPRJn9vy_TWxWvuLoOfSFBw" type="text/javascript"></script>

    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAA1XbMiDxx_BTCY2_FkPh06RRaGTYH6UMl8mADNa0YKuWNNa8VNxQEerTAUcfkyrr6OwBovxn7TDAH5Q"></script>                                 

    <script type="text/javascript"> 

    var map; 

    var geocoder;

    var address=sel.options[sel.selectedIndex].value;
    document.write(address);

    //sess = address;
    //session.setAttribute("sess1",sess);

    function createMarker(point,html,what) 

    {

        var marker = new GMarker(point,{id:what, name:"foo", description:"baz"});

        GEvent.addListener(marker, "mouseover", function() {

        marker.openInfoWindowHtml(html);

        });

        return marker;

     }

    function initialize() 
    { 

        map = new GMap2(document.getElementById("map_canvas")); 

        map.addControl(new GLargeMapControl());

        map.addControl(new GScaleControl());

        map.setCenter(new GLatLng(79, 0, true), 8); 

        map.addControl(new GMenuMapTypeControl(true,false));

        var point1 = map.getCenter();

        var marker = createMarker(point1,'<img src="printers-for-wire-and-network-elements-marking-43844.jpg" width="100" height="100">',"this")

        map.addOverlay(marker);

        geocoder = new GClientGeocoder();                       

    }


    function addAddressToMap(response) { 

     map.clearOverlays(); 

     if (!response || response.Status.code != 200) { 

       alert("Sorry, we were unable to geocode that address");

     } else { 

       place = response.Placemark[0];

       point = new GLatLng(place.Point.coordinates[1], 

                           place.Point.coordinates[0]); 
        //var test = 'ajaykumar';
        //alert(test);
      var marker = createMarker(point,'<form action="/Details.jsp"><input type="image" name="b" value="click" src="printers-for-wire-and-network-elements-marking-43844.jpg" width="100" height="100"></form>',"this");

      map.addOverlay(marker); 
      marker.openInfoWindowHtml('<b>Coordinates:</b>' + place.Point.coordinates); 
     }

    }

    function showLocation(sel) 
    { 

     address = sel.options[sel.selectedIndex].value;
     geocoder.getLocations(address, addAddressToMap); 

    } 

    function findLocation(address)
    { 

     showLocation(); 

    }

    function find()
    { 

     window.open("/Details.jsp","winA","width=300,height=300,resizeable=no")

    }


 </script> 

  </head> 

  <body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border: 0 none;"> 


  <form name="f1" action="#" onsubmit="showLocation(); return false;">

  <p> 
        <TABLE ALIGN="CENTER">
        <b>Search cities:</b>


        <%
            try 
            {
                Class c = Class.forName("org.postgresql.Driver");
                //out.print(c);

                connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres","postgres", "password");

                statement = connection.createStatement();               

                set = statement.executeQuery("SELECT sno,city,ip,sysname FROM test");


        %>
            <select name="htmlcombo" onchange="showLocation(this)">
        <%
            while(set.next())
            {

        %>
            <option value=<%= set.getString(2)%>> <%= set.getString(2)%> </option>

        <%  } 

        %>
            </select>

            </TABLE>

        <%

            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        %>
      </p> 

    </form>


    <div id="map_canvas" style="width: 1250px; height: 740px"></div>
    <form>
    <%
    try{
        out.print(set.getString(2));
    %>

    <%
    }
    catch(Exception e)
    {}
    %>
    </form>

  </body>

I need the selected value in my 2.jsp file on clicking of the image on the marker.

2.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page import="java.sql.*" %>

        <%
            int i=1;
            Connection connection = null;
            boolean foundResults = false;
            ResultSet set = null;
            Statement statement = null;
            String city;
            String ip;
            String sysname;

            //String getCity=(String)session.getAttribute("sess1");
            //out.print(getCity);

            String val=request.getParameter("htmlcombo");
            out.print(val);



            //out.print(request.getQueryString());

            try 

            {
                Class.forName("org.postgresql.Driver");

                connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", 
                                           "postgres", "password");

                statement = connection.createStatement();               

                set = statement.executeQuery("SELECT sno,city,ip,sysname FROM test where city='"+val+"'");

                while(set.next())
                {
                    city=set.getString(2);
                    ip=set.getString(3);
                    sysname=set.getString(4);
                    out.print(city+"<br>");
                    out.print(ip+"<br>");
                    out.print(sysname+"<br>");
                    out.print("<br><br>");

                }
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        %>


Related Tutorials/Questions & Answers:
Retriving value from dropdown list nad disply it in other page
Retriving value from dropdown list nad disply it in other page  Hello, I have a dropdownbox on my webpage and a map which contains a marker... of the selected value from the dropdown list and dispaly it to on the next page. i
help to select a value from the dropdown list
help to select a value from the dropdown list  I have a html file... from the drop down list created in a div and put it in the textbox kim... <input type="text" size="30" name="inputString" value="" id="inputString
Advertisements
how to set value of dropdown list
how to set value of dropdown list  Hello Sir, I'd solved the earlier problems somehow but now this time another problem arised when I want to pass the value from a link to a dropdown list. I want to set the dropdown list selected
how to set value of dropdown list
how to set value of dropdown list  Hello Sir, I'd solved the earlier problems somehow but now this time another problem arised when I want to pass the value from a link to a dropdown list. I want to set the dropdown list selected
how to add data dynamically from database into a dropdown list in a jsp
how to add data dynamically from database into a dropdown list in a jsp ... and department fields also.I have a create an jsp page in which there should 2 drop down list.In that first list is for department and the 2nd list for the names
How to access Contacts from gmail using LDAP in JSP dropdown list
How to access Contacts from gmail using LDAP in JSP dropdown list  HI, I am creating a JSP page in which i have to make a dropdown box, and access gmail contacts in that drop downlist using LDAP. Can any one plz help me out
dropdown list in jsp
dropdown list in jsp  hai, i have static dropdown list.. i want to get the selected value in string variable without jsp regards asha
Not retriving the validations from validation.xml - Struts
Not retriving the validations from validation.xml  I have create the file called register.jsp    LoginID: Password: when i
how can i send a mail to a particular user from a many user dropdown list in jsp
how can i send a mail to a particular user from a many user dropdown list in jsp  how can i a sent a user question to a particular person from a drop down list in jsp
jsp- database dependent dropdown list
jsp- database dependent dropdown list   i want 2 dropdown list 1- CLASS 2-SECTION both are should come from database. and if i select a class suppose class a the corresponding section dropdown list should retrieve the section
retriving image from database - JSP-Servlet
retriving image from database  how to retrive image from mysql database by using servlet programming  Hi Friend, Please visit the following link: http://www.roseindia.net/servlets/retreiveimage.shtml Thanks
loading value into combo box by selecting value from other combo box - JSP-Servlet
loading value into combo box by selecting value from other combo box  ... is that as i select state from state_combo_box,then the next combo box is dynamically... in same JSP page. please help me
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 database. but unable to store the selected value in database table. please help
Dropdown Checkbox list
Dropdown Checkbox list This tutorial explains how to create jquery Dropdown... jquery Dropdown Checkbox list. The application directory structure should look like... dropdown , then displays dropdown list as checkbox  You can
How to pass the value from controller to jsp page ?
How to pass the value from controller to jsp page ?  HI I need to pass the value from controller to jsp. I use the way like this Controller request.setAttribute("msg", "Successfully Login"); In jsp ${msg} and then i
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
Calling Servlet to build a List of data from database and show this on the JSP page in table
Calling Servlet to build a List of data from database and show this on the JSP... to retrieve all the data from database and then add the data into list. The list is then added to the request object and sen to JSP page. On the JSP page this value
Retriving data from MYSQL without line break using java
Retriving data from MYSQL without line break using java  get data without line breaking from mysql table (i.e data stored as mediumtext )using java
reading dropdown values from properties file in jsp
reading dropdown values from properties file in jsp  reading dropdown values from properties file in jsp
dropdown
dropdown  I have a dropdown having 2 options-"Open"& "closed".When i select "open" option the related rows of data are retrieved from database and same with the other option.My database is Mysql and coding in PHP
how to perform the client side validations to the dropdown list using javascript?
how to perform the client side validations to the dropdown list using javascript?  Hi Good Morning! This is Prasad, I want to perform the client side validation to the dropdown list using javascript. So give me sample.I am
dropdown
dropdown  how to select an item from the dropdownlist when we load the page   Hi Friend, Try the following code: <html> <head>... = v.options[v.selectedIndex].value; alert(str); } </script> </head>
retriving data from sql server using jsp code and placing them in text fields of html code
retriving data from sql server using jsp code and placing them in text fields of html code  Hi, my question is how to retrieve data from sql... jhon address abbanna clolony my html page is <table> <form id
linking php page to other php pages
linking php page to other php pages  How to link the PHP Page to other PHP page
Pass value of rasio button from jsp page to action class(not conventional problem)
Pass value of rasio button from jsp page to action class(not conventional problem)  Hi, I have a jsp page that has code which goes ike this: <table border="1"> <tbody> <s:iterator value
Get JTextField value from another class
value from other class. For this, we have created two classes ClassA.java and ClassB.java. In ClassA, we have defined a textbox 'text1' that will get the value from... Get JTextField value from another class   
Subtraction of a date from Sql and other from java.
Subtraction of a date from Sql and other from java.  I want to subtract a date that i retrieve from mysql database with the system date that i retrieve from java. I want the difference between the two date in the integer form
Retriving data stored in database
Retriving data stored in database  Hi, How to retrive data from my sql database using Hibernate,Spring and tapestry please give me an example.I am new to this Hibernate and Spring
retrieving data in to the dropdown box from postgresql database in core java
retrieving data in to the dropdown box from postgresql database in core... have selected '"+value+"' from ComboBox"); } }); f.add... the error to bring a right of codes to execute.Thanks in advance. //first page
Iterate list of objects on jsp page
Iterate list of objects on jsp page  Hi, I want to iterate the list of objects on jsp page using custom tags. Can you please give me one link or example? Thanks
image displaying from database with some other information
image displaying from database with some other information  hi... only a cross mark is shows. same code runs if i am not retriveing any data from... table entries. <%@ page import="java.io.*"%> <html xmlns="http
Select from select list + display
Select from select list + display  i have a select list containing... select EmpCode from the select list, the corresponding EmpName and DeptName should...)ajax.jsp: <%@page import="java.sql.*"%> <html> <head> <
populate dropdown box
populate dropdown box  hi, Is there any ways in which i can populate my dropdown menu with values from 1 to n (n = the value stored in database)using java script or jsp, either is fine? Ex: If value corresponding to selected
Pass value from JSP to JavaScript
Pass value from JSP to JavaScript       We can also pass the value from a JSP page to the java... a function hello() which takes value from the jsp page on click of some button
session value not get in many jsp page.
session value not get in many jsp page.  I am using servlet to set...,response); and get session value on jsp page by follwing:- String user=(String... page its give null value
SPEL-Wiring values from other bean properties
SpEL: Wiring value from other bean properties Spring 3 provides powerful... take an example to demonstrate how SpEL is used to wire value from other bean...}, #{part2.name}, #{part3.name}. Here the value of the name property of each object
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...: function hello(){ var w = document.form.sel.selectedIndex; var value
Dynamic Dropdown Menu
records from your database in a drop down menu/list box. You can apply...: Whenever we select any field as auto_increment, value starts from 1...']; } ?> <? $list=mysql_query("select * from car_list
retrive the data from access database to drop down list box in jsp
retrive the data from access database to drop down list box in jsp  hai, im new to jsp now im using the jsp along with access database.in table i load all the data's i need to retrive the data from database to dropdown list box
retrive the result of a serach string from other sites - JSP-Servlet
retrive the result of a serach string from other sites  Sir, suppose i have create my own websites, and i want to search an item in my sites and as well as from other search sites and i want to show all the search result in my
Retriving multiple values of checkboxes in struts
Retriving multiple values of checkboxes in struts  how to retrive...="lang" value="C/C++">C/C++<br> <input type="checkbox" name="lang" value="JAVA">Java<br> <input type="checkbox" name="lang" value="C
Read the value from XML in java
Read the value from XML in java  Hi, i have an XML... the permissions on that file.So how can i read that value. This is little urgent.... <param name="file" value="D:/Lakki
Return Value from One Form
Return Value from One Form  I have two buttons in main form client and bank.when i click client button new form will open, in this dedupe button... value of dedupe form and use in bank form..how to do
Retrieve Value from Table - Hibernate
Retrieve Value from Table   Hai friend, I need help, How can i retrieve values From database using hibernate in web Application. As I new to hibernate I couldn't find solution for this problem.. Can anyone help please.. 
Retrieving attribute value from XML
Retrieving attribute value from XML  I have an XML as below to parse...; ..... But am not able to fetch the value of LoadTicketId attribute. My code...-values-from-a-nodel.shtml http://www.roseindia.net/xml/dom/GetData.shtml Thanks
receiving null value in back bean by the jsf page
receiving null value in back bean by the jsf page  i have done above things but i m receiving null value in back bean by the jsf page plz tell me solution as soon as possible
Calling a jsp page from Servlet
Calling a jsp page from Servlet  How can I do this? Suppose I have jsp page aaa.jsp. From aaa.jsp on form action I have made a call to a servlet... List and data is being retrieve. Now I want to pass this List to another jsp page
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
How to store data entered in JSP page by a user in XML file & later retrieval of data using id at other page
How to store data entered in JSP page by a user in XML file & later retrieval of data using id at other page  I have made a form in JSP having emp id... in another jsp page using retrieve submit button.Please tell step by step instructions
dropdown in struts - Struts
dropdown in struts  how to populate a drop down from database entries... write the query (in which file)to get the list from database and how and where can i set the list to context to get it from there in a collection object
 

 

 

DMCA.com