File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes how to transfer data from javascript to jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to transfer data from javascript to jsp" Watch "how to transfer data from javascript to jsp" New topic

how to transfer data from javascript to jsp

dineshiop kumar

Joined: Mar 05, 2009
Posts: 13
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">

<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>jQuery Example 3</title>

<script type="text/javascript" language="javascript" src="WEB-INF/jquery-1.2.6.js"></script>
<script type="text/javascript" language="javascript" src="WEB-INF/jquery.validate.js"></script>
<script type="text/javascript" language="javascript">
//Our validation script will go here.
//validation implementation will go here.
rules: {
txtFirstName: {
required: true
txtLastName: {
required: true,
minlength: 2
messages: {
txtFirstName: {
required: "* Required"
txtLastName: {
required: "* Required",
minlength: "* 2 Characters Required."


<style type="text/css">
#container {
width: 350px;
height: 8em;
border: 1px #009933 solid;

label, input{
margin:2px 0px 1px 4px;

label {
font-family:"Times New Roman", Times, serif;

<div id="container">
<form id="secondform.jsp" method ="get">
<label for="txtFirstName">First Name: </label><br />
<input name="txtFirstName" type="text" id="txtFirstName" title="Please Enter a First Name" /><br />
<label for="txtLastName">Last Name:</label><br />
<input name="txtLastName" type="text" id="txtLastName" title="Pleaes Enter a Last Name"/><br />
<input type="submit" value="Submit" id="btnSubmit" />

Surya Kant
Ranch Hand

Joined: Mar 29, 2005
Posts: 104
Where is the JSP?What actually you are trying to say?
Muhammad Ijaz
Ranch Hand

Joined: Mar 03, 2009
Posts: 34
Use hidden fields to place data from javascript to jsp. On the event of Onclick or Onsubmit etc.., call the javascript function that will place the data into the hidden fields of the form.


IBM Certified WebSphere Commerce Application Developer

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

So what is your question? Simply posting a bunch of unformatted code isn't going to get you much help.

Also, please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information. You can go back and change your post to add code tags by clicking the button on your post.

And finally, as this is a JavaScript, not a JSP question, it has been moved to a more appropriate forum.

[Asking smart questions] [About Bear] [Books by Bear]
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
To the point: you use input fields to send request parameters to the server side. To send hidden input values, use input type="hidden". To set those values using Javascript, just access and alter the HTML DOM the usual way.

Fairly simple all.
I agree. Here's the link:
subject: how to transfer data from javascript to jsp
It's not a secret anymore!