?
Solved

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

Posted on 2010-01-07
6
Medium Priority
?
1,337 Views
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.
0
Comment
Question by:kbb1
6 Comments
 
LVL 28

Expert Comment

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

Expert Comment

by:rrz
ID: 26206674
0
 

Author Comment

by:kbb1
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
0
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
request.getParameter('hidden1');
0
 
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
 document.getElementById("hiddenFiled").value="NSK";

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

Accepted Solution

by:
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.  
<html>
      <head>
            <style>
                   form{display:none; }
            </style>
            <script>
                    function SubmitForm(){
                                document.myHiddenForm.param1.value = "1234";
                                document.myHiddenForm.submit();
                    }
            </script>
      </head>
<body>
      <button type="button" name="mybutton" onclick="SubmitForm();" >submitHiddenForm</button>
      <form name="myHiddenForm" method="post" action="parameters.jsp" >
      <input type="text" name="param1" />
      </form>
</body>
</html>

Open in new window

0

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