0

I want to move this piece of Java code to a JSP file.

IReader reader = new SomeReader<SomeClass>() {

    @Override
    protected SomeClass createNode() {
        return new SomeClass();
    }
};

I get this error:

Unable to compile class for JSP:

Syntax error, insert "}" to complete ClassBody

I don't see this syntax (Java Anonymous Class) being supported in JSP. What is an alternative to this?

Using Java 8 - Zulu JDK (old project).

Ajit Panigrahi
  • 752
  • 10
  • 27
  • [Not using scriptlets at all](https://stackoverflow.com/questions/38340291/jsp-what-is-wrong-with-scriptlets-and-what-to-use-instead) (I personally try to get rid of JSP entirely). – chrylis -cautiouslyoptimistic- Sep 21 '21 at 14:59
  • @chrylis-cautiouslyoptimistic- Thanks for the reference. I am using this in an old project where standard JSP is our best bet for having REST API endpoints which we feed to different frontends. I found a solution (read: workaround) to this which I will add as an answer shortly. – Ajit Panigrahi Sep 23 '21 at 11:50

0 Answers0