I have a JSP in some legacy code that declares some functions:
<%!
String func1(String A) {
}
String func2(String B) {
}
%>
Other code includes these JSPs, and just calls func1
and func2
directly.
I want to move those functions to java without modification, so Intellij can operate on them reasonably (show warnings, refactor, etc.) without upgrading Intellij to use JSPs.
I want to move them directly (i.e. cut and paste) without having to rewrite them, because there are thousands of lines of code. I also want the function calls in all the other JSPs to remain valid, so I don't have to rewrite them.
How can I do this?
I see the servlet intro page, which hints that I could replace the JSP with a servlet, but it's not quite clear how. Also, I have hundreds of files that include the existing JSP, so I don't want to delete the page, just have all its functions be defined in a Java.
I also see example questions showing how to declare functions, but not really how to declare some of those functions in Java.
EDIT:
From this answer, I am using
- Server Version: Apache Tomcat/7.0.108
- Servlet Version: 3.0
- JSP Version: 2.2
Yes, it's old. This is a legacy app.