1

I have a jsp page with some java code and jsp functions. Please find the code below.

   <%
        try {
            client.removeOAuthApplicationData(consumerkey);
            String message = resourceBundle.getString("app.removed.successfully");
            CarbonUIMessage.sendCarbonUIMessage(message,CarbonUIMessage.INFO, request);
        } catch (Exception e) {
            String message = resourceBundle.getString("error.while.removing.app");
            CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request,e);
            forwardTo ="../admin/error.jsp";
        }
    %>
    <script type="text/javascript">
        function forward() {
            alert('forward');
            location.href = "<%=forwardTo%>";
        }
        function createAppOnclick() {
            alert('testtt');
    }
</script>

<script type="text/javascript">
    createAppOnclick();
    forward();

</script>

I need to call createAppOnclick function once the java code finishes executing. Once I execute this it calls first the createAppOnclick function. I am bit new to javascript and jsp and appreciate your help.

Thanks

1 Answer 1

3

Javascript plays on client side and Java&JSP plays on server side.

What you can do is

Call your all javascript functions in your document load (onready) function so that they can execute while the page load.

You cannot run those functions on server.

Note : How to avoid Java code in JSP files?

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

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.