0

<% String successmessage=(String)request.getAttribute("sm");%>

I have alert.js file in my eclipse how can I transfer successmessage variable from JSP to javascript for alert message

0

1 Answer 1

0

Put it in a hidden span and query for it. e.g:

<span hidden id="successMessage">
  <%= request.getAttribute("sm")%>
</span>

and make sure you got your HTML escaping figured out!

Then in javascript:

const msg = document.getElementById("successMessage").textContent;

There are many others, but given that you're using JSP, it sounds like the dated stuff is what you're looking for.

Sign up to request clarification or add additional context in comments.

1 Comment

Got it, it's helped me

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.