how to pass form values from javascript of html page to jsp page

how to pass form values from javascript of html page to jsp page

This is my sample html page which contains inline javascript which calculates the geocode and tries to return the lattitude and longitude .But my question is how to submit all the form values with lattitude and longitude returned from showlocation funtion to submitform.jsp page and display latitude value in jsp page .

Index.html

    <html>
    <head>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA5yM-fP6TPUheIXxW3TxpVRRgJAR_YXLeqIBw9Qs7Dzlh-4wFexRUVFiN8RbSageQjhAggT3jom"
    type="text/javascript"></script>
<script type="text/javascript"
    src="http://maps.google.com/maps/api/js?sensor=false">
</script>

    <script type="text/javascript">
    geocoder = new GClientGeocoder();
     function showlocation() {
            var clientaddress = document.getElementById('addstreetname').value;
            geocoder.getLocations(clientaddress, function(response) {
                if (!response || response.Status.code != 200) {
                    alert("Sorry, we were unable to geocode the first address");

                }
                else {
                    var lat1 = response.Placemark[0].Point.coordinates[1];
                    var lng1 = response.Placemark[0].Point.coordinates[0];

                    return {latitude: lat1, longitude: lng1};
        }
            });
    </script>
    </head>
    <body>
    <form id="addresslistingform" action="submitform.jsp" onsubmit="returnshowlocation();">
                Company_Name:<br/>
                      <input size="30" type="text" id="businessname" name="businessname"/><br/>
                    Zipcode:<br/>
                      <input size="30" type="text" id="zipcode"  name="zipcode1"/><br/>
                    Street No:<br/>
                      <input size="30" type="text" id="addstreetno" name="streetno"/><br/>
                    Street Name:<br/> 
                      <input size="30" type="text" id="addstreetname"  name="streetname"/><br/>
                    State:<br/>                  
                      <select name="select2" id="select2" class="required" name="state" >
                        <option value="">Select Your State</option>
                        <option value="1"> karnataka</option>
                        <option value="2"> Kerala</option>
                       <option value="3"> Andhra Pradesh</option>
                       </select>
    </form>
    </body>
    </html>

submitform.jsp

<%@ page language="java" import="java.sql.*" %>

     <%
            String driver = "com.mysql.jdbc.Driver";
                Class.forName(driver).newInstance();
            Connection con=null;
            ResultSet rst=null;
            Statement stmt=null;

        try{
            String url = "jdbc:mysql://localhost:3306/";
                String dbName = "db";
                String driverName = "com.mysql.jdbc.Driver";
                String userName = "";
                String password = "";


            con = DriverManager.getConnection(url+dbName, userName, password);
            stmt=con.createStatement();
        }catch(Exception e){
                System.out.println(e.getMessage());
              }


     String Company_Name=request.getParameter("businessname");
     String Zipcode =request.getParameter("zipcode1");
    String Street_Number=request.getParameter("streetno");
    String Street_Name=request.getParameter("streetname");
    String State= request.getParameter("state");    
   String Latitude=request.getParameter("Latitude");
    out.println("latitude is :"+request.getParameter("Latitude"));

          %>
View Answers









Related Tutorials/Questions & Answers:
how to pass form values from javascript of html page to jsp page
how to pass form values from javascript of html page to jsp page   This is my sample html page which contains inline javascript which calculates... to submit all the form values with lattitude and longitude returned from
How to pass parametes from JSP page to HTML page? - JSP-Servlet
How to pass parametes from JSP page to HTML page?  Hi all, In my project I have one JSP page and one HTML page. In JSP page I have created HTML... to pass the values from my JSP page to HTML page. Pls help me out. Hitendra 
Advertisements
how to pass values from 2nd page tp 3rd page....
how to pass values from 2nd page tp 3rd page....  Hi, How to pass values from 2nd page to 3rd page..... here are my programs(not exactly correct...; Login1.jsp : In dis , to get the values from Login.jsp,i ve used: <form
How to retrieve array values from html form to jsp?
How to retrieve array values from html form to jsp?  Hi! I am... it into jsp. Means i just want to retrieve values from html form containing array... sample code for how to retrive array values from html to jsp.   hi friend
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
How to pass multiple values from a servlet to JSP?
How to pass multiple values from a servlet to JSP?  hi, I want to pass multiple values form a servlet to JSP. Hw do i do that? I am able to send one value at a time without any prb, but I am unable to carry multiple (from two
Pass values from form to form
Pass values from form to form       Java program to pass values from one form to another form... to only pass values from one page to another consecutive page which is being
how to set values from parent page to iframe in javascript
how to set values from parent page to iframe in javascript  how to set values from parent page to iframe in javascript pls reply me as possible as I am in great trouble
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below here there are list of radio buttons here in jsp page when the values are matched from database. I want to pass the selected value in Struts Action FormBean
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below here there are list of radio buttons here in jsp page when the values are matched from database. I want to pass the selected value in Struts Action FormBean
How to pass Array of string from action class to jsp page
How to pass Array of string from action class to jsp page  this is my... jsp page is <%-- Document : select_service Created on : Aug 31...="text/html"%> <%@page pageEncoding="UTF-8"%> <%@ taglib uri="http
how to pass input from radio button to jsp page
how to pass input from radio button to jsp page  hi.. the code below here there are list of radio buttons here in jsp page when the values are matched from database. I want to pass the selected value in Struts Action FormBean
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... script from the HTML page. Since in JSP page we can embed HTML tags as well. 
passing values form javascript - JSP-Interview Questions
passing values form javascript  please i want to pass values from javascript function to jsp code how can i do
Displaying the values in text fields of a form from a javascript function in jsp
Displaying the values in text fields of a form from a javascript function... to call a javascript function by passing 3 values from applet. And i have to display these values in 3 text fields of a form in the current web page. Here form
How to fetch entries/values from database to a jsp page one by one?
How to fetch entries/values from database to a jsp page one by one?  I have a table in Microsoft SQL server Management Studio with two columns title and data and each column has 10 enteries. I have a jsp page on which i want
how to pass string array from action class to jsp page? pls reply me.
how to pass string array from action class to jsp page? pls reply me.  how to pass string array from action class to jsp page? pls reply me.  ...); And through your jsp page, get array values. <% try { String[] str = (String
[JSP] How to pass back ID to previous page.
[JSP] How to pass back ID to previous page.  Hi experts, May I ask something. How to link a page to previous page which the content in previous page is selected from database where IDPRODUCT=". I don't know how to pass back
how to pass the mutiple values from <Ui:datagrid hyperlink - JSP-Servlet
how to pass the mutiple values from    I am getting the error when passing the values from this way emp2=${employee.lastName1} & name=${employee.firstName.How to pass the values from hyperlink in column
how to pass the mutiple values from <Ui:datagrid hyperlink - JSP-Servlet
how to pass the mutiple values from      Hi Friend, Please post your full code. Thanks
How to redirect from a HTML page?
How to redirect from a HTML page?  Hi, Is it possible to redirect from HTML page to another page on the net? I have one page and I want to redirect... to redirect to another page using HTML code. You can use the following code: <meta
how to pass variable from simple java main class(not servlet) to the jsp page?
how to pass variable from simple java main class(not servlet) to the jsp page?  I have a simple Java class in which I invoke a call to a JSP page... from the simple Java class to the JSP page. How can I do that? Here is my
pass radio button values to next page
pass radio button values to next page  how to pass selected radio button values which coming from mysql database to next page using php. Please show me with examples
Hi how to transfer table data from html page to excel sheet by using javascript .
Hi how to transfer table data from html page to excel sheet by using javascript .  html page to excel sheet by using javascript and i dont want to transfer all rows in table, i want to hide some rows in excel sheet. Please send
how to get a values from a multipart/form-data - JSP-Servlet
how to get a values from a multipart/form-data  Dear sir , I... ,matter,file field values but not status and from field i am getting null values and also the file is not uploading the content type in other jsp it is showing
JSP Value to JavaScript
to pass the value from JSP to JavaScript. The JavaScript create a function that accepts the value from the jsp page.  Understand with ExampleADS_TO_REPLACE_1 In this section, we are going to pass the jsp value to javaScript. For this we
Values from servlet into dropdownlist in jsp page using ajax
Values from servlet into dropdownlist in jsp page using ajax  1) jsp...;%@ page language="java" contentType="text/html; charset=ISO-8859-1...); } } } Im not able to get values retrived from
how to create a slider on jsp page n slider has values from 0-4
how to create a slider on jsp page n slider has values from 0-4  i want to create a slider on jsp page and slider has values from 0-4   Using the jquery, you can create a slider in jsp. <html> <head> <
Search page form in jsp
Search page form in jsp  search form in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
How to pass javascript variable in Scriplet of JSP?
How to pass javascript variable in Scriplet of JSP?  How can I assign the value of a javascript variable to a variable declared in jsp scriplet? Is it possible
how to retrieve text and images from mysql database and show on html page using jsp servlet
how to retrieve text and images from mysql database and show on html page using jsp servlet  <%@ page language="java" contentType="text/html... {color:blue} <%@ page import="java.sql.*" %> <%@ page import
passing textbox value from one page to another page using html n javascript
passing textbox value from one page to another page using html n javascript  on button onclick event pass text box value and i want to pass value... on the othe (next/prevoious)page please help me   1)page1.html: <html>
how to give link from jsp to jsp page
how to give link from jsp to jsp page  hi this is my following code... language="java"%> <%@page import="java.sql.*"%> <form method="post" action... file is Modify but here i have to give modifyUser.jsp file but i don't khow how
how to give link from jsp to jsp page
how to give link from jsp to jsp page  hi this is my following code... language="java"%> <%@page import="java.sql.*"%> <form method="post" action... file is Modify but here i have to give modifyUser.jsp file but i don't khow how
JSP to add details to a database from a HTML form.
JSP to add details to a database from a HTML form.  Hi I'm a second year CS student who has to use JSP to validate a HTML form and add the details...; <%@ page contentType = "text/html" %> <%@ taglib uri="http
How To Page Refresh Using JavaScript In JSP
How To Page Refresh Using JavaScript In JSP....   Step 1: Create a web page(sign.jsp) to show a button to Login user. ADS_TO_REPLACE_2 <%@ page import="java.sql.*" %>
Pass parameters from JSP to Servlet
Pass parameters from JSP to Servlet In this section, you will learn how to pass parameters from JSP page to servlet. For this purpose, we have used...: <%@page language="java"%> <% request.setAttribute("Company
calling java method from html form with out using javascript - JSP-Servlet
calling java method from html form with out using javascript  How can i call java method from a HTML form, java script should be disabled?  ...;script LANGUAGE="JavaScript">function testResults(form
How to get the text from textarea in HTML and store it in database using javascript and jsp
How to get the text from textarea in HTML and store it in database using javascript and jsp  How to get the text from textarea in HTML and store it in database using javascript and jsp <script> function str() { <
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
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: <... button) to be deleted On clicking 'delete' button . Hence I need to pass eventId
How to pass an arraylist from servlet to jsp?
How to pass an arraylist from servlet to jsp?  Hello, Can anyone please tell me how to pass an arraylist from servlet to jsp? I have two arraylist one of type String and the other int. How to send both the arraylists from
how to add the calendar to the dynamic rows in html or jsp page - JSP-Servlet
how to add the calendar to the dynamic rows in html or jsp page   Hi Sir, i have 3 columns in my jsp page date of payment,amount recieved,no and i have 2 button in my jsp page ADD and delete button. when i click on add
How to insert data into databse by JSP form registration page in netbeans
How to insert data into databse by JSP form registration page in netbeans  ... of data for login purpose. I have created 1 form in JSP netbeans with both username.... & how to connect tht form to my databse , so it can store data?   1
How to extract HTML elements from a page?
HTML Scrapping: How to extract HTML elements from a page? In this tutorial we are going to teach you how to extract the HTML elements from a web page... for extracting HTML element from a page. We will extract the data from the html table
How to extract HTML elements from a page?
HTML Scrapping: How to extract HTML elements from a page? In this tutorial we are going to teach you how to extract the HTML elements from a web page...; So, we have learned how to extract the html elements from the web page
program to enter values from one jsp page and then do calculation on some formula and that results is displayed in another jsp
program to enter values from one jsp page and then do calculation on some formula and that results is displayed in another jsp  <%@ page language="java" import="java.util.*;"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
Sending form data from HTML page to SQLserver 2005 database by calling servlet code
Sending form data from HTML page to SQLserver 2005 database by calling servlet code  Hi sir, I would like to know how to send the form data from html page to database by calling servlet code from html page .   
Example program to pass value from Html to java script
;TITLE> Pass value from HTML to JavaScript </TITLE> <script... Example program to pass value from Html to java script       We can also pass the values from
problem in sending more than 500 values to a jsp page
problem in sending more than 500 values to a jsp page  when i am trying to send more than 500 values from a html form to a jsp page browser is showing that server is not sending any data...I have configured tomcat5.5

Ads