how to pass values from javascript to servlet without adding inthe URL

Posted on 2010-01-07
Medium Priority
Last Modified: 2013-11-21
I am getting somevalues in the javascript function, now i want to send these values to servlet without putting these in the URL. since my values contain special characters, if i add it in the URL and send it to Servelt , getting errors. Can anybody help me on how to pass values from javascript to servlet without adding in theURL.
Question by:kbb1
LVL 28

Expert Comment

ID: 26206635
You should use post as your method.  
<form  method="post"    ...
LVL 28

Expert Comment

ID: 26206674

Author Comment

ID: 26207243
i am getting some values based on <td> id . there is no form here, so i cannt pass it by post method.
my code is something like

var checkedRow = document.getElementById(j);
                    var checkedCells = checkedRow.getElementsByTagName("td");
                         var title =checkedCells[1].innerText;
              var size=checkedCells[2].innerText;
          var maxlimit=checkedCells[3].innerText;

and i need to dispaly these values thorugh a servlet
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 26207368
insert these values to a hidden input
<input type='hidden' name='hidden1' id='hidden1'>

and fetch these values in the servlet by
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 26207414
use hidden filed !!

set the value to the flied in java script

like this

now u can get the form flied values in ur servlet as ur other flied getting  !!
LVL 28

Accepted Solution

rrz earned 2000 total points
ID: 26212147
You didn't tell us what you want to occur after you submit values to the server.
Do you want to refresh the page ?
Do you want to go to another page ?
Do you want to stay on same page with no action ?  

> there is no form here  
You can hide the form by using CSS. You can also programmatically  submit it. Please look at example code below here.  

If you don't want any action, then you could use AJAX.  
                   form{display:none; }
                    function SubmitForm(){
                                document.myHiddenForm.param1.value = "1234";
      <button type="button" name="mybutton" onclick="SubmitForm();" >submitHiddenForm</button>
      <form name="myHiddenForm" method="post" action="parameters.jsp" >
      <input type="text" name="param1" />

Open in new window


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
What You Need to Know when Searching for a Webhost Provider
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question