JSP calling a function from another jsp file
Hi i have开发者_StackOverflow中文版 a JSP file , while trying to add code i got the 64k limit error. so i decided to add the code to another jsp file and include it inside the first one.
so i have
first.jsp
.....
<jsp:include page="second.jsp"/>
....
<%= foo(); %>
second.jsp ....
<%!
public String foo()
{
return "test";
}
>%
i try using this and i get this error message: "The method foo is undefined for the type first_jsp"
any idea what is the problem and how i can solve this ?
This is the wrong way to do it.
First, if you want some method, create a Java class, and import it using <%@ page import="your.package.YourClass*" %>
Second, don't use scriptlets in the JSP page at all. Use JSTL. Possibly JSTL functions. See here
Stop using scriptlets. Use JSTL tags to access your data and write your Java code in servlets/regular java classes.
精彩评论