Want to pass the java value into javascript function in jsp
24,349
it's work for me :
<html:submit property = "save" styleClass = "button_c" onclick = "return SubmitPage('<%=timeVal %>')">Save</html:submit>
('<%=timeVal %>') // between single Quotation
Comments
-
NoNaMe over 3 years
I am trying to pass a string value to a JavaScript function by taking from request parameter in JSP, in my struts based project. here is the code:
<% String timeVal = "Not found"; if(request.getAttribute("myDate")!=null){ timeVal= (String)request.getAttribute("myDate"); } %>
and then pass it in function as parameter
<html:submit property = "save" styleClass = "button_c" onclick = "return SubmitPage('update', <%=timeVal %>)">Save</html:submit>
Where the JavaScript function is
function SubmitPage(action, aa) { alert("Date is ...." + aa); }
But when i try to run this it gives me an error
HTTP Status 400 - Request[/AMResourceLibraryListAction] does not contain handler parameter named ref
With message on web page.
Request[/AMResourceLibraryListAction] does not contain handler parameter named ref
Thanks in advance.
EDIT Here is stack trace
[ERROR] DispatchAction - -Request[/AMResourceLibraryListAction] does not contain handler parameter named ref
-
NoNaMe about 11 yearsThis way avoid the exception but take <%=timeVal %> as string not variable
-
NoNaMe about 11 yearsThis way avoid the exception but take <%=timeVal %> as string not variable
-
mehdi about 11 yearsin this question
timeVal
is a String, If it is not, can Convert? -
NoNaMe about 11 yearstimeVal is a variable of type String having variable value... that i am getting from a servlet....