0
function printthis()
{ 
 var content_vlue = document.getElementById('print_content').innerHTML;
 var target= 'printValue?value1='+content_vlue;
 document.forms[0].action = target;
 document.forms[0].submit();
}

<div id="print_content">hello i am good</div>

For frontend I am using JSP. While executing this code to get the value in servlet

String msg = request.getParameter("value1");

While executing this code the browser url changes to printValue?

But I am unable to get the value of value1

Please suggest me...

0

2 Answers 2

1

Seems you are missing value1='+content_vlue from the request try this and see

var target= "'printValue?value1="+content_vlue+"'";
Sign up to request clarification or add additional context in comments.

Comments

0

Create a hidden variable inside your form like this

<form ..>
    ....
    <input type="hidden" id="value1" name="value1"/>
</form>

and modify javascript function to this .

function printthis()
{ 
 var content_vlue = document.getElementById('print_content').innerHTML;
 document.getElementById('value1').value  = content_value;
 var target= 'printValue';
 document.forms[0].action = target;
 document.forms[0].submit();
}

Hope this will work for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.