Search code examples
javascriptjspscriptlet

Calling Javascript function inside JSP scriplet


I have a javascript function that needs to be called under a condition.

The condition is given below

<%if(request.getAttribute("isValidUser").equals("false"))
  {%>
     Redirect();
<%}%>

Redirect() is the function name that I have declared and defined in the section.

When I execute the page I am getting the following error.

    org.apache.jasper.JasperException: An exception occurred 
    processing JSP page /HomePage.jsp at line 136

HomePage.jsp:

133:      <p><input type="password" name="password" id="password" placeholder="Password"/></p>
134:      <span id="nullPassword" class="error"></span>
135:   </div><span style="color:red;">
136:   <%if(request.getAttribute("isValidUser").equals("false"))
137:   {%>
138:        Redirect();
139:   <%}%>

Please help me out.

Thank you.


Solution

  • I don't have enough rep points to comment, but it looks like your js function call should be in script tags.