JSP not working in Eclipse Orion WebIDE

50 Views Asked by At

Does Eclipse Orion WebIDE support JSP? I am trying to create a simple application and jsp files are not working.

index.html

<html>
<head>
    <script type="text/javascript" src="jquery-1.12.4.js"></script>
    <script>
        function getInput()
        {
            $.ajax({
                type:"GET",    
                url: "./test.jsp",
                  success: function(success) {
                    console.log(success);
                  }
                });
        }
    </script>
</head>
 <body onload="getInput()">

test.jsp

<%@import="./javaMethod*"%>
<%javaMethod a = new javaMethod();
    var value = a.initiate();
%>
<input type="hidden" id="test" value="<%=value%>">

javaMethod.java

public class javaMethod
{
    public int initiate()
    {
        return 1;
    }
}

This should add a hidden input field which will hold the value from the java method. However, it is not working and the jsp is just displaying as plain text.

1

There are 1 best solutions below

0
Jozef Chocholacek On

This should add a hidden input field - no, this should log anything comes from test.jsp to the browser console. To add the output of the JSP to the body element, use $(document.body).append(success);.